Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit bfb954a

Browse files
authored
Merge pull request #209 from joce/colourize-markdown-code
Mark relevant code blocks as `csharp` for colourization`
2 parents 7cbf99f + a7be9c3 commit bfb954a

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

README-ZH.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ UIWidgets主要来自[Flutter](https://github.com/flutter/flutter)。但UIWidget
4848
将下载的包文件夹移动到Unity项目的Package文件夹中。
4949

5050
通常,你可以在控制台(或终端)应用程序中输入下面的代码来完成这个操作:
51-
51+
5252
```none
5353
cd <YourProjectPath>/Packages
5454
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
@@ -78,7 +78,7 @@ UI Canvas。
7878
UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建应用程序并在Unity编辑器中播放。
7979
1. 创建一个新C#脚本,命名为“UIWidgetsExample.cs”,并将以下代码粘贴到其中。
8080

81-
```none
81+
```csharp
8282
using System.Collections.Generic;
8383
using Unity.UIWidgets.animation;
8484
using Unity.UIWidgets.engine;
@@ -89,24 +89,24 @@ UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建
8989
using Unity.UIWidgets.widgets;
9090
using UnityEngine;
9191
using FontStyle = Unity.UIWidgets.ui.FontStyle;
92-
92+
9393
namespace UIWidgetsSample {
9494
public class UIWidgetsExample : UIWidgetsPanel {
9595
protected override void OnEnable() {
96-
// if you want to use your own font or font icons.
96+
// if you want to use your own font or font icons.
9797
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
98-
99-
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
98+
99+
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
100100
// a TextStyle object
101-
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
101+
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
102102
// FontStyle.italic);
103-
103+
104104
// add material icons, familyName must be "Material Icons"
105105
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
106106
107107
base.OnEnable();
108108
}
109-
109+
110110
protected override Widget createWidget() {
111111
return new WidgetsApp(
112112
home: new ExampleApp(),
@@ -118,19 +118,19 @@ UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建
118118
)
119119
);
120120
}
121-
121+
122122
class ExampleApp : StatefulWidget {
123123
public ExampleApp(Key key = null) : base(key) {
124124
}
125-
125+
126126
public override State createState() {
127127
return new ExampleState();
128128
}
129129
}
130-
130+
131131
class ExampleState : State<ExampleApp> {
132132
int counter = 0;
133-
133+
134134
public override Widget build(BuildContext context) {
135135
return new Column(
136136
children: new List<Widget> {
@@ -193,7 +193,7 @@ UIWidgets也支持Gif!
193193
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
194194

195195
此插件覆盖了Unity WebGL构建模块中的如下参数:
196-
```
196+
```none
197197
JS_SystemInfo_GetWidth
198198
JS_SystemInfo_GetHeight
199199
JS_SystemInfo_GetCurrentCanvasWidth
@@ -214,7 +214,7 @@ $JSEvents
214214
## 调试UIWidgets应用程序
215215

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

@@ -238,7 +238,7 @@ UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以
238238
#### Wiki
239239

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

244244
| 问题 | 回答 |
@@ -247,7 +247,7 @@ UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以
247247
| 我可以使用UIWidgets构建游戏UI吗? | 可以 |
248248
| 我可以使用UIWidgets开发Unity编辑器插件吗? | 可以 |
249249
| UIWidgets是UGUI / NGUI的扩展吗? | 不是 |
250-
| UIWidgets只是Flutter的副本吗? | 不是 |
250+
| UIWidgets只是Flutter的副本吗? | 不是 |
251251
| 我可以通过简单的拖放操作来创建带有UIWidgets的UI吗? | 不可以 |
252252
| 我是否需要付费使用UIWidgets? | 不需要 |
253253
| 有推荐的适用于UIWidgets的IDE吗? | Rider, VSCode(Open .sln) |

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
## Introduction
66

7-
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
8-
cross-platform Apps using the Unity Engine.
7+
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
8+
cross-platform Apps using the Unity Engine.
99

1010
UIWidgets is mainly derived from [Flutter](https://github.com/flutter/flutter). However, taking advantage of
11-
the powerful Unity Engine, it offers developers many new features to improve their Apps
11+
the powerful Unity Engine, it offers developers many new features to improve their Apps
1212
as well as the develop workflow significantly.
1313

1414

@@ -17,7 +17,7 @@ Using the latest Unity rendering SDKs, a UIWidgets App can run very fast and kee
1717

1818

1919
#### Cross-Platform
20-
A UIWidgets App can be deployed on all kinds of platforms including PCs, mobile devices and web page directly, like
20+
A UIWidgets App can be deployed on all kinds of platforms including PCs, mobile devices and web page directly, like
2121
any other Unity projects.
2222

2323
#### Multimedia Support
@@ -54,11 +54,11 @@ Install **Unity 2018.3** or above. You can download the latest Unity on https://
5454
#### UIWidgets Package
5555
Visit our Github repository https://github.com/UnityTech/UIWidgets
5656
to download the latest UIWidgets package.
57-
57+
5858
Move the downloaded package folder into the **Package** folder of your Unity project.
5959

6060
Generally, you can make it using a console (or terminal) application by just a few commands as below:
61-
61+
6262
```none
6363
cd <YourProjectPath>/Packages
6464
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
@@ -67,10 +67,10 @@ Generally, you can make it using a console (or terminal) application by just a f
6767
## Getting Start
6868

6969
#### i. Overview
70-
In this tutorial, we will create a very simple UIWidgets App as the kick-starter. The app contains
70+
In this tutorial, we will create a very simple UIWidgets App as the kick-starter. The app contains
7171
only a text label and a button. The text label will count the times of clicks upon the button.
7272

73-
First of all, please open or create a Unity Project and open it with Unity Editor.
73+
First of all, please open or create a Unity Project and open it with Unity Editor.
7474

7575
And then open Project Settings, go to Player section and **add "UIWidgets_DEBUG" to the Scripting Define Symbols field.**
7676
This enables the debug mode of UIWidgets for your development. Remove this for your release build afterwards.
@@ -80,15 +80,15 @@ A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps
8080
UI Canvas in Unity.
8181
1. Create a new Scene by "File -> New Scene";
8282
1. Create a UI Canvas in the scene by "GameObject -> UI -> Canvas";
83-
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
83+
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
8484
**Image** Component from the Panel.
8585

8686
#### iii. Create Widget
8787
A UIWidgets App is written in **C# Scripts**. Please follow the steps to create an App and play it
8888
in Unity Editor.
8989

9090
1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it.
91-
```none
91+
```csharp
9292
using System.Collections.Generic;
9393
using Unity.UIWidgets.animation;
9494
using Unity.UIWidgets.engine;
@@ -99,24 +99,24 @@ in Unity Editor.
9999
using Unity.UIWidgets.widgets;
100100
using UnityEngine;
101101
using FontStyle = Unity.UIWidgets.ui.FontStyle;
102-
102+
103103
namespace UIWidgetsSample {
104104
public class UIWidgetsExample : UIWidgetsPanel {
105105
protected override void OnEnable() {
106-
// if you want to use your own font or font icons.
106+
// if you want to use your own font or font icons.
107107
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
108-
109-
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
108+
109+
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
110110
// a TextStyle object
111-
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
111+
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
112112
// FontStyle.italic);
113-
113+
114114
// add material icons, familyName must be "Material Icons"
115115
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
116-
116+
117117
base.OnEnable();
118118
}
119-
119+
120120
protected override Widget createWidget() {
121121
return new WidgetsApp(
122122
home: new ExampleApp(),
@@ -128,19 +128,19 @@ in Unity Editor.
128128
)
129129
);
130130
}
131-
131+
132132
class ExampleApp : StatefulWidget {
133133
public ExampleApp(Key key = null) : base(key) {
134134
}
135-
135+
136136
public override State createState() {
137137
return new ExampleState();
138138
}
139139
}
140-
140+
141141
class ExampleState : State<ExampleApp> {
142142
int counter = 0;
143-
143+
144144
public override Widget build(BuildContext context) {
145145
return new Column(
146146
children: new List<Widget> {
@@ -165,14 +165,14 @@ in Unity Editor.
165165
}
166166
}
167167
```
168-
168+
169169
1. Save this script and attach it to **Panel 1** as its component.
170170
1. Press the "Play" Button to start the App in Unity Editor.
171171

172172
#### iv. Build App
173173
Finally, the UIWidgets App can be built to packages for any specific platform by the following steps.
174174
1. Open the Build Settings Panel by "File -> Build Settings..."
175-
1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
175+
1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
176176
all relevant resources and generate the final App package.
177177

178178
#### How to load images?
@@ -186,34 +186,34 @@ UIWidgets supports Gif as well!
186186
3. Use Image.asset("loading1.gif") to load the gif images.
187187

188188
#### Using Window Scope
189-
If you see the error ```AssertionError: Window.instance is null``` or null pointer error of ```Window.instance```,
189+
If you see the error `AssertionError: Window.instance is null` or null pointer error of `Window.instance`,
190190
it means the code is not running in the window scope. In this case, you can enclose your code
191191
with window scope as below:
192-
```
192+
```csharp
193193
using(WindowProvider.of(your gameObject with UIWidgetsPanel).getScope()) {
194-
// code dealing with UIWidgets,
194+
// code dealing with UIWidgets,
195195
// e.g. setState(() => {....})
196196
}
197197
```
198198

199199
This is needed if the code is in methods
200-
not invoked by UIWidgets. For example, if the code is in ```completed``` callback of ```UnityWebRequest```,
201-
you need to enclose them with window scope.
200+
not invoked by UIWidgets. For example, if the code is in `completed` callback of `UnityWebRequest`,
201+
you need to enclose them with window scope.
202202
Please see [HttpRequestSample](./Samples/UIWidgetSample/HttpRequestSample.cs) for detail.
203-
For callback/event handler methods from UIWidgets (e.g ```Widget.build, State.initState...```), you don't need do
203+
For callback/event handler methods from UIWidgets (e.g `Widget.build, State.initState...`), you don't need do
204204
it yourself, since the framework ensure it's in window scope.
205205

206206
#### Show Status Bar on Android
207207
Status bar is always hidden by default when an Unity project is running on an Android device. If you
208208
want to show the status bar in your App, this
209-
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
209+
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
210210
compatible to UIWidgets, therefore can be used as a good option before we release our
211-
full support solution on this issue.
212-
211+
full support solution on this issue.
212+
213213
Besides,
214214
please set "Render Outside Safe Area" to true in the "Player Settings" to make this plugin working properly on Android P or later.
215-
216-
215+
216+
217217

218218

219219
#### Automatically Adjust Frame Rate
@@ -230,15 +230,15 @@ Please select the plugin of the Unity version corresponding to your project, and
230230
If you need to disable this plugin for any reason, please disable all the versions of this plugin as described above.
231231

232232
This plugin overrides the following parameters in the Unity WebGL building module:
233-
```
233+
```none
234234
JS_SystemInfo_GetWidth
235235
JS_SystemInfo_GetHeight
236236
JS_SystemInfo_GetCurrentCanvasWidth
237237
JS_SystemInfo_GetCurrentCanvasHeight
238238
$Browser
239239
$JSEvents
240240
```
241-
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.
241+
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.
242242
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.
243243
All the modifications introduced in `UIWidgetsCanvasDevicePixelRatio` are marked by `////////// Modifcation Start ////////////` and `////////// Modifcation End ////////////`.
244244
In the marked codes, all the multiplications and divisions with `devicePixelRatio` are introduced by our modification.
@@ -247,37 +247,37 @@ To learn about the original script in detail, please refer to `SystemInfo.js` an
247247
#### Image Import Setting
248248
Unity, by default, resizes the width and height of an imported image to the nearest integer that is a power of 2.
249249
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.
250-
250+
251251
## Debug UIWidgets Application
252252

253253
#### Define UIWidgets_DEBUG
254-
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
254+
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
255255
debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this:
256-
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
257-
and add **UIWidgets_DEBUG**.
256+
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
257+
and add **UIWidgets_DEBUG**.
258258
The symbol is for debug purpose, please remove it from your release build.
259259

260260
#### UIWidgets Inspector
261261
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
262-
via *Window/Analysis/UIWidgets* inspector in Editor menu.
262+
via *Window/Analysis/UIWidgets* inspector in Editor menu.
263263
**Note**
264-
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
264+
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
265265
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
266266

267267
## Learn
268268

269269
#### Samples
270-
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
270+
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
271271
Feel free to try them out and make modifications to see the results.
272272
To get started, the UIWidgetsTheatre scene provides you
273273
a list of carefully selected samples to start with.
274274

275-
You can also try UIWidgets-based Editor windows by clicking **UIWidgetsTest** on the main menu
275+
You can also try UIWidgets-based Editor windows by clicking **UIWidgetsTest** on the main menu
276276
and open one of the dropdown samples.
277277

278278
#### Wiki
279279
The develop team is still working on the UIWidgets Wiki. However, since UIWidgets is mainly derived from Flutter,
280-
you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs
280+
you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs
281281
from those of their Flutter counterparts.
282282
Meanwhile, you can join the discussion channel at (https://connect.unity.com/g/uiwidgets)
283283

@@ -289,7 +289,7 @@ Meanwhile, you can join the discussion channel at (https://connect.unity.com/g/u
289289
| Can I use UIWidgets to build game UIs? | **Yes** |
290290
| Can I develop Unity Editor plugins using UIWidgets? | **Yes** |
291291
| Is UIWidgets a extension of UGUI/NGUI? | **No** |
292-
| Is UIWidgets just a copy of Flutter? | **No** |
292+
| Is UIWidgets just a copy of Flutter? | **No** |
293293
| Can I create UI with UIWidgets by simply drag&drop? | **No** |
294294
| Do I have to pay for using UIWidgets? | **No** |
295295
| Any IDE recommendation for UIWidgets? | **Rider, VSCode(Open .sln)** |

0 commit comments

Comments
 (0)