浏览代码

SafeArea fix + readme update

/main
xingwei.zhu 6 年前
当前提交
52ec62d6
共有 3 个文件被更改,包括 40 次插入26 次删除
  1. 53
      README.md
  2. 5
      Runtime/editor/editor_window.cs
  3. 8
      Runtime/engine/WidgetCanvas.cs

53
README.md


# UI Widgets
# UIWidgets
UIWidget is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
UIWidget is mainly derived from Flutter @https://github.com/flutter/flutter. However, taking advantage of
UIWidgets is mainly derived from Flutter @https://github.com/flutter/flutter. However, taking advantage of
Using the latest Unity rendering SDKs, a UIWidget App can run very fast and keep >60fps in most times.
Using the latest Unity rendering SDKs, a UIWidgets App can run very fast and keep >60fps in most times.
A UIWidget App can be deployed on all kinds of platforms including PCs, mobile devices and web page directly, like
A UIWidgets App can be deployed on all kinds of platforms including PCs, mobile devices and web page directly, like
#### 3D-Support
Except for basic 2D UIs, developers are also able to include 3D Models, particle-systems to their UIWidget Apps.
#### Multimedia Support
Except for basic 2D UIs, developers are also able to include 3D Models, audios, particle-systems to their UIWidgets Apps.
A UIWidget App can be debug in the Unity Editor directly with many advanced tools like
A UIWidgets App can be debug in the Unity Editor directly with many advanced tools like
CPU/GPU Profiling, FPS Profiling.

Install **Unity 2018.3** or above. You can download the latest Unity on https://unity3d.com/get-unity/download.
#### UIWidget Package
#### UIWidgets Package
to download the latest UIWidget package.
to download the latest UIWidgets package.
Move the downloaded package folder into the **Package** folder of your Unity project.

## Getting Start
#### i. Overview
In this tutorial, we will create a very simple UIWidget App as the kick-starter. The app contains
In this tutorial, we will create a very simple UIWidgets App as the kick-starter. The app contains
A UIWidget App is usually built upon a Unity UI Canvas. Please follow the steps to create a
A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a
UI Canvas in Unity.
1. Create a new Scene by "File -> New Scene";
1. Create a UI Canvas in the scene by "GameObject -> UI -> Canvas";

#### iii. Create Widget
A UIWidget App is written in **C# Scripts**. Please follow the steps to create an App and play it
A UIWidgets App is written in **C# Scripts**. Please follow the steps to create an App and play it
in Unity Editor.
1. Create a new C# Script named "ExampleCanvas.cs" and paste the following codes into it.

1. Press the "Play" Button to start the App in Unity Editor.
#### iv. Build App
Finally, the UIWidget App can be built to packages for any specific platform by the following steps.
Finally, the UIWidgets App can be built to packages for any specific platform by the following steps.
1. Open the Build Settings Panel by "File -> Build Settings..."
1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
all relevant resources and generate the final App package.

#### Samples
You can find many UIWidget App samples in the UIWidget package in the **Samples** folder.
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
You can also try UIWidget-based Editor windows by clicking **UIWidgetsTest** on the main menu
You can also try UIWidgets-based Editor windows by clicking **UIWidgetsTest** on the main menu
The develop team is still working on the UIWidget Wiki. However, since UIWidget is mainly derived from Flutter,
you can refer to Flutter Wiki to access detailed descriptions of UIWidget APIs
The develop team is still working on the UIWidgets Wiki. However, since UIWidgets is mainly derived from Flutter,
you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs
| :-----------------------------------------------| -----------: |
| Can I create standalone App using UIWidget? | **Yes** |
| Can I use UIWidget to build game UIs? | **Yes** |
| Can I develop Unity Editor plugins using UIWidget? | **Yes** |
| Is UIWidget a extension of UGUI/NGUI? | **No** |
| Is UIWidget just a copy of Flutter? | **No** |
| Can I create UI with UIWidget by simply drag&drop? | **No** |
| Do I have to pay for using UIWidget? | **No** |
| :-----------------------------------------------| ---------------------: |
| Can I create standalone App using UIWidgets? | **Yes** |
| Can I use UIWidgets to build game UIs? | **Yes** |
| Can I develop Unity Editor plugins using UIWidgets? | **Yes** |
| Is UIWidgets a extension of UGUI/NGUI? | **No** |
| Is UIWidgets just a copy of Flutter? | **No** |
| Can I create UI with UIWidgets by simply drag&drop? | **No** |
| Do I have to pay for using UIWidgets? | **No** |
| Any IDE recommendation for UIWidgets? | **Rider, VSCode(Open .sln)** |
## How to Contribute
If you want to join us, please contact us via Github and we will respond as soon as possible.

5
Runtime/editor/editor_window.cs


get { return this._alive; }
}
protected virtual void updateSafeArea() {
}
public void OnEnable() {
this._devicePixelRatio = this.queryDevicePixelRatio();
var size = this.queryWindowSize();

this._lastWindowWidth * this._devicePixelRatio,
this._lastWindowHeight * this._devicePixelRatio);
this.updateSafeArea();
D.assert(this._surface == null);
this._surface = this.createSurface();

this._lastWindowWidth * this._devicePixelRatio,
this._lastWindowHeight * this._devicePixelRatio);
this.updateSafeArea();
if (this.onMetricsChanged != null) {
this.onMetricsChanged();
}

8
Runtime/engine/WidgetCanvas.cs


readonly WidgetCanvas _widgetCanvas;
bool _needsPaint;
protected override void updateSafeArea() {
this._padding = new WindowPadding(
Screen.safeArea.x,
Screen.safeArea.y,
Screen.width - Screen.safeArea.width,
Screen.height - Screen.safeArea.height);
}
public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
this._needsPaint = true;

正在加载...
取消
保存