浏览代码

Mark relevant code blocks as `csharp` for colourization`

/main
joce 6 年前
当前提交
c4d49e22
共有 2 个文件被更改,包括 64 次插入64 次删除
  1. 34
      README-ZH.md
  2. 94
      README.md

34
README-ZH.md


将下载的包文件夹移动到Unity项目的Package文件夹中。
通常,你可以在控制台(或终端)应用程序中输入下面的代码来完成这个操作:
```none
cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets

UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建应用程序并在Unity编辑器中播放。
1. 创建一个新C#脚本,命名为“UIWidgetsExample.cs”,并将以下代码粘贴到其中。
```none
```csharp
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;

using Unity.UIWidgets.widgets;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
// if you want to use your own font or font icons.
// if you want to use your own font or font icons.
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),

)
);
}
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {

如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
此插件覆盖了Unity WebGL构建模块中的如下参数:
```
```none
JS_SystemInfo_GetWidth
JS_SystemInfo_GetHeight
JS_SystemInfo_GetCurrentCanvasWidth

## 调试UIWidgets应用程序
#### 定义UIWidgets_DEBUG
我们建议在Unity编辑器中定义 UIWidgets_DEBUG 脚本符号,这将打开UIWidgets中的调试断言(debug assertion),有助于更早发现潜在的Bug。
我们建议在Unity编辑器中定义 UIWidgets_DEBUG 脚本符号,这将打开UIWidgets中的调试断言(debug assertion),有助于更早发现潜在的Bug。
因此选择 **Player Settings** > **Other Settings** > **Configuration** > **Scripting Define Symbols** ,并添加 UIWidgets_DEBUG。
该符号仅供调试使用,请在发布版本中删除它。

#### Wiki
目前开发团队仍在改进UIWidgets Wiki。 由于UIWidgets主要来源于Flutter,你也可以参考Flutter Wiki中与UIWidgets API对应部分的详细描述。同时,你可以加入我们的讨论组( https://connect.unity.com/g/uiwidgets )。
#### 常问问题解答
| 问题 | 回答 |

| 我可以使用UIWidgets开发Unity编辑器插件吗? | 可以 |
| UIWidgets是UGUI / NGUI的扩展吗? | 不是 |
| UIWidgets只是Flutter的副本吗? | 不是 |
| UIWidgets只是Flutter的副本吗? | 不是 |
| 我可以通过简单的拖放操作来创建带有UIWidgets的UI吗? | 不可以 |
| 我是否需要付费使用UIWidgets? | 不需要 |
| 有推荐的适用于UIWidgets的IDE吗? | Rider, VSCode(Open .sln) |

94
README.md


## Introduction
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
cross-platform Apps using the Unity Engine.
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
cross-platform Apps using the Unity Engine.
the powerful Unity Engine, it offers developers many new features to improve their Apps
the powerful Unity Engine, it offers developers many new features to improve their Apps
as well as the develop workflow significantly.

#### Cross-Platform
A UIWidgets 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
any other Unity projects.
#### Multimedia Support

#### UIWidgets Package
Visit our Github repository https://github.com/UnityTech/UIWidgets
to download the latest UIWidgets package.
```none
cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets

#### i. Overview
In this tutorial, we will create a very simple UIWidgets 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
First of all, please open or create a Unity Project and open it with Unity Editor.
First of all, please open or create a Unity Project and open it with Unity Editor.
And then open Project Settings, go to Player section and **add "UIWidgets_DEBUG" to the Scripting Define Symbols field.**
This enables the debug mode of UIWidgets for your development. Remove this for your release build afterwards.

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";
1. Add a Panel (i.e., **Panel 1**) to the UI Canvas by right click on the Canvas and select "UI -> Panel". Then remove the
1. Add a Panel (i.e., **Panel 1**) to the UI Canvas by right click on the Canvas and select "UI -> Panel". Then remove the
**Image** Component from the Panel.
#### iii. Create Widget

1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it.
```none
```csharp
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;

using Unity.UIWidgets.widgets;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
// if you want to use your own font or font icons.
// if you want to use your own font or font icons.
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),

)
);
}
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {

}
}
```
1. Save this script and attach it to **Panel 1** as its component.
1. Press the "Play" Button to start the App in Unity Editor.

1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
all relevant resources and generate the final App package.
#### How to load images?

3. Use Image.asset("loading1.gif") to load the gif images.
#### Using Window Scope
If you see the error ```AssertionError: Window.instance is null``` or null pointer error of ```Window.instance```,
If you see the error `AssertionError: Window.instance is null` or null pointer error of `Window.instance`,
```
```csharp
// code dealing with UIWidgets,
// code dealing with UIWidgets,
not invoked by UIWidgets. For example, if the code is in ```completed``` callback of ```UnityWebRequest```,
you need to enclose them with window scope.
not invoked by UIWidgets. For example, if the code is in `completed` callback of `UnityWebRequest`,
you need to enclose them with window scope.
For callback/event handler methods from UIWidgets (e.g ```Widget.build, State.initState...```), you don't need do
For callback/event handler methods from UIWidgets (e.g `Widget.build, State.initState...`), you don't need do
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
full support solution on this issue.
full support solution on this issue.
#### Automatically Adjust Frame Rate

If you need to disable this plugin for any reason, please disable all the versions of this plugin as described above.
This plugin overrides the following parameters in the Unity WebGL building module:
```
```none
JS_SystemInfo_GetWidth
JS_SystemInfo_GetHeight
JS_SystemInfo_GetCurrentCanvasWidth

```
If you would like to implement your own WebGL plugin, and your plugin overrides at least one of the above parameters, you need to disable the `UIWidgetsCanvasDevicePixelRatio` plugin in the above mentioned way to avoid possible conflicts.
If you would like to implement your own WebGL plugin, and your plugin overrides at least one of the above parameters, you need to disable the `UIWidgetsCanvasDevicePixelRatio` plugin in the above mentioned way to avoid possible conflicts.
If you still need the function provided by this plugin, you can mannually apply the modification to Unity WebGL building module introduced in this plugin.
All the modifications introduced in `UIWidgetsCanvasDevicePixelRatio` are marked by `////////// Modifcation Start ////////////` and `////////// Modifcation End ////////////`.
In the marked codes, all the multiplications and divisions with `devicePixelRatio` are introduced by our modification.

Unity, by default, resizes the width and height of an imported image to the nearest integer that is a power of 2.
In UIWidgets, you should almost always disable this by selecting the image in the "Project" panel, then in the "Inspector" panel set the "Non Power of 2" option (in "Advanced") to "None", to prevent your image from being resized unexpectedly.
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
and add **UIWidgets_DEBUG**.
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
and add **UIWidgets_DEBUG**.
via *Window/Analysis/UIWidgets* inspector in Editor menu.
via *Window/Analysis/UIWidgets* inspector in Editor menu.
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
You can also try UIWidgets-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
you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs
you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs
from those of their Flutter counterparts.
Meanwhile, you can join the discussion channel at (https://connect.unity.com/g/uiwidgets)

| 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** |
| 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)** |

正在加载...
取消
保存