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

Commit a2d30e3

Browse files
authored
Merge pull request #371 from UnityTech/fix_emoji
Update emoji resources to apple.
2 parents d847468 + a22102d commit a2d30e3

File tree

9 files changed

+645
-267
lines changed

9 files changed

+645
-267
lines changed

Documentation~/com.unity.uiwidgets.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ Status bar is always hidden by default when an Unity project is running on an An
228228
#### Automatically Adjust Frame Rate
229229

230230
To build an App that is able to adjust the frame rate automatically, please open Project Settings, and in the Quality tab, set the "V Sync Count" option of the target platform to "Don't Sync".
231-
The default logic is to set the frame rate to 25 when the screen is static, and change the frame rate to 60 whenever the screen changes.
232-
If you would like to modify the behavior of speeding up or cooling down the frame rate, please set `Window.onFrameRateSpeedUp` and/or `Window.onFrameRateCoolDown` to your own functions.
231+
The default logic is to reduce the frame rate when the screen is static, and change it back to 60 whenever the screen changes.
232+
If you would like to disable this behavior, please set `Window.onFrameRateSpeedUp` and `Window.onFrameRateCoolDown` to null function, i.e., () => {}.
233+
234+
Note that in Unity 2019.3 and above, UIWidgets will use OnDemandRenderAPI to implement this feature, which will greatly save the battery.
233235

234236
#### WebGL Canvas Device Pixel Ratio Plugin
235237
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
@@ -258,12 +260,34 @@ Unity, by default, resizes the width and height of an imported image to the near
258260
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.
259261

260262
#### Update Emoji
261-
UIWidgets supports rendering emoji in (editable) texts. The emoji images comes from the free
262-
resources provided by [Google Emoji](https://emojipedia.org/google). If you would
263-
like to use your own images for emoji, please update the texture image `Tests/Resources/Emoji.png`,
264-
and the unicode-index table in `Runtime/ui/txt/emoji.cs` which maps unicodes to specific locations
265-
in the texture. Specifically, remember to update the Dictionary `emojiLookupTable`, number of rows
266-
in the texture `rowCount`, and number of columns `colCount`.
263+
UIWidgets supports rendering emoji in (editable) texts.
264+
The default emoji resource version is [iOS 13.2](https://emojipedia.org/apple/ios-13.2).
265+
We also prepared the resources of [Google Emoji](https://emojipedia.org/google).
266+
To switch to Google version of emoji, please follow the following steps:
267+
268+
1. Copy `Runtime/Resources/backup~/EmojiGoogle.png` to `Runtime/Resources/images` folder.
269+
2. In the **Project** panel, find and select `EmojiGoogle` asset, and in the **Inspector** panel, change **Max Size** to 4096, and disable **Generate Mipmaps**.
270+
3. In the `OnEnable()` function in your class overriding `UIWidgetsPanel`, add the following code
271+
272+
```csharp
273+
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
274+
```
275+
276+
If you would like to use your own images for emoji, please follow the following steps:
277+
278+
1. Create the sprite sheet (take `EmojiGoogle.png` as an example), and put in a `Resources` folder in your project, (for example `Resources/myImages/MyEmoji.png`).
279+
2. In the `OnEnable()` function, add the following code (replace example values with actual value). Note that the order of emoji codes should be consistent with the sprite sheet.
280+
281+
```csharp
282+
EmojiUtils.configuration = new EmojiResourceConfiguration(
283+
spriteSheetAssetName: "myImage/MyEmoji",
284+
emojiCodes: new List<int> {
285+
0x1f004, 0x1f0cf, 0x1f170, ...
286+
},
287+
spriteSheetNumberOfRows: 36,
288+
spriteSheetNumberOfColumns: 37,
289+
);
290+
```
267291

268292
#### Interact with GameObject Drag&Drops
269293

@@ -273,8 +297,6 @@ in the texture `rowCount`, and number of columns `colCount`.
273297

274298
With the provided packaged stateful widget `UnityObjectDetector` and its `onRelease` callback function, you can easily drag some objects (for example GameObject from Hierarchy, files from Project Window, etc) into the area, get the UnityEngine.Object[] references and make further modification.
275299

276-
Please refer to "UIWidgetsTests -> Drag&Drop" for simple examples.
277-
278300

279301
## Debug UIWidgets Application
280302

@@ -288,20 +310,27 @@ The symbol is for debug purpose, please remove it from your release build.
288310
#### UIWidgets Inspector
289311
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
290312
via *Window/Analysis/UIWidgets* inspector in Editor menu.
313+
291314
**Note**
292315
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
293316
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
294317

295318
## Learn
296319

297320
#### Samples
298-
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
299-
Feel free to try them out and make modifications to see the results.
300-
To get started, the UIWidgetsTheatre scene provides you
301-
a list of carefully selected samples to start with.
302-
303-
You can also try UIWidgets-based Editor windows by clicking **UIWidgetsTest** on the main menu
321+
You can find many UIWidgets sample projects on Github, which cover different aspects and provide you
322+
learning materials in various levels:
323+
* UIWidgetsSamples (https://github.com/UIWidgets/UIWidgetsSamples). These samples are developed by the dev team in order to illustrates all the features of
324+
UIWidgets. First clone this Repo to the **Assets** folder of your local UIWidgets project. Then
325+
you can find all the sample scenes under the **Scene** folder.
326+
You can also try UIWidgets-based Editor windows by clicking the new **UIWidgetsTests** tab on the main menu
304327
and open one of the dropdown samples.
328+
* awesome-UIWidgets by Liangxie (https://github.com/liangxiegame/awesome-uiwidgets). This Repo contains
329+
lots of UIWidget demo apps and third-party applications.
330+
* ConnectApp (https://github.com/UnityTech/ConnectAppCN). This is an online, open-source UIWidget-based App developed
331+
by the dev team. If you are making your own App with UIWidgets, this project will provides you with
332+
many best practice cases.
333+
305334

306335
#### Wiki
307336
The develop team is still working on the UIWidgets Wiki. However, since UIWidgets is mainly derived from Flutter,

Documentation~/index-zh.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ UIWidgets也支持Gif!
194194

195195
#### 七、自动调节帧率
196196
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
197-
默认的逻辑是在界面静止时将帧率降低为25,在界面变动时将帧率提高至60。
198-
如果您需要修改帧率升高或降低时的行为,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为您自己的函数。
197+
默认的逻辑是在界面静止时将帧率降低,在界面变动时再将帧率提高至60。
198+
如果您不想开启该功能,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为空函数,()=> {}即可。
199+
200+
在Unity 2019.3版本及以上,UIWidgets将使用OnDemandRenderAPI来实现帧率调节,它将在不影响UI响应速度的情况下大幅降低耗电和发热问题。
199201

200202
#### 八、WebGL Canvas分辨率调整插件
201203
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
@@ -223,9 +225,34 @@ $JSEvents
223225
在UIWidgets中使用图片时,记得将这一特性关闭,以免图片被意外放缩,方法如下:在Project面板中选中图片,在"Inspector"面板中将"Non Power of 2"(在"Advanced"中)设置为"None"。
224226

225227
#### 十、更新表情(Emoji)
226-
UIWidgets支持渲染文本中包含的表情。表情的图片来自[Google Emoji](https://emojipedia.org/google)提供的免费资源。
227-
如果您希望使用自己的表情图片,请更新纹理图`Tests/Resources/Emoji.png`,以及`Runtime/ui/txt/emoji.cs`中将Unicode映射到纹理图中具体位置的映射表。
228-
特别地,请记得更新Dictionary变量`emojiLookupTable`,纹理图的行数`rowCount`以及纹理图的列数`colCount`
228+
UIWidgets支持渲染文本中包含的表情。
229+
默认的表情资源为[iOS 13.2](https://emojipedia.org/apple/ios-13.2)
230+
我们也准备了[Google Emoji](https://emojipedia.org/google)的表情资源。
231+
如果您希望切换到Google版本的表情,请按如下步骤操作:
232+
233+
1. 拷贝`Runtime/Resources/backup~/EmojiGoogle.png``Runtime/Resources/images`目录。
234+
2.**Project**面板中,找到`EmojiGoogle`资源,在**Inspector**面板中,将**Max Size**更改为4096,并取消**Generate Mipmaps**选项前的对勾。
235+
3. 在您的代码中继承`UIWidgetsPanel`的类的`OnEnable()`函数中,添加如下代码
236+
237+
```csharp
238+
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
239+
```
240+
241+
如果您希望使用自己的表情图片,请按如下步骤操作:
242+
243+
1. 参照`EmojiGoogle.png`,创建您自己的Emoji表单,并放到工程目录下的某个`Resources`目录中,例如`Resources/myImages/MyEmoji.png`)。
244+
2.`OnEnable()`函数中,添加如下代码(记得将示例的值改为真实的值)。注意Emoji的编码的顺序要和Emoji表单一致。
245+
246+
```csharp
247+
EmojiUtils.configuration = new EmojiResourceConfiguration(
248+
spriteSheetAssetName: "myImage/MyEmoji",
249+
emojiCodes: new List<int> {
250+
0x1f004, 0x1f0cf, 0x1f170, ...
251+
},
252+
spriteSheetNumberOfRows: 36,
253+
spriteSheetNumberOfColumns: 37,
254+
);
255+
```
229256

230257
#### 十一、与GameObject进行拖拽交互
231258

@@ -235,8 +262,6 @@ UIWidgets支持渲染文本中包含的表情。表情的图片来自[Google Emo
235262

236263
我们提供了一个包装好的`UnityObjectDetector`组件以及`onRelease`回调函数,借此您可以实现简单地将物体(例如Hierarchy内的场景物体、Project窗口下的文件等)拖拽至区域内,来获得`UnityEngine.Object[] `类型的引用并进行操作。
237264

238-
你可以在“UIWidgetsTests -> Drag&Drop”下找到简单的实例样例。
239-
240265

241266
## 调试UIWidgets应用程序
242267

@@ -256,15 +281,22 @@ UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以
256281

257282
## 学习
258283

259-
#### 示例
260-
261-
你可以在**Samples**文件夹的UIWidgets包中找到一些精心挑选的UIWidgets应用示例,并通过这些示例来开始你的学习。请随意尝试并进行修改以查看结果。
284+
#### 教程
262285

263-
你也可以在支持**UIWidgets**的编辑器中,点击主菜单上的UIWidgets,并在下拉窗口中选择一个示例。
286+
包括开发组在内的广大开发者为UIWidgets提供了许多可供学习的样例和教程,你可以根据你的需求进行学习:
287+
- UIWidgets官方示例。目前所有官方使用的示例项目均维护在一个独立的Github仓库( https://github.com/UIWidgets/UIWidgetsSamples )中。你可以
288+
将它clone到你项目本地的Assets目录下使用。
289+
具体的,你可以在Sample项目的**Scene**子文件夹中浏览所有示例UI场景。
290+
此外,你还可以点击主菜单上的新增的UIWidgetsTests选项卡,并在下拉菜单中选择一个EditorWindow UI示例来运行。
291+
- UIWidgets凉鞋系列教程。你可以在凉鞋老师整理的Github仓库( https://github.com/liangxiegame/awesome-uiwidgets )中学习UIWidgets的基本用法
292+
以及许多有趣的小Demo。
293+
- ConnectApp开源项目。这是一个完整的线上、开源、完全基于UIWidgets的第一方App项目。其中包含了大量产品级的UIWidgets工程实践细节,
294+
如果你想深入了解UIWidgets并且使用它构建线上项目,请访问项目Github仓库了解更多( https://github.com/UnityTech/ConnectAppCN )。
264295

265296
#### Wiki
266297

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

269301
#### 常问问题解答
270302

@@ -280,4 +312,4 @@ UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以
280312
| 有推荐的适用于UIWidgets的IDE吗? | Rider, VSCode(Open .sln) |
281313

282314
## 如何贡献
283-
请查看[CONTRIBUTING](CONTRIBUTING)
315+
请查看[CONTRIBUTING.md](CONTRIBUTING.md)

Documentation~/index.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ Status bar is always hidden by default when an Unity project is running on an An
228228
#### Automatically Adjust Frame Rate
229229

230230
To build an App that is able to adjust the frame rate automatically, please open Project Settings, and in the Quality tab, set the "V Sync Count" option of the target platform to "Don't Sync".
231-
The default logic is to set the frame rate to 25 when the screen is static, and change the frame rate to 60 whenever the screen changes.
232-
If you would like to modify the behavior of speeding up or cooling down the frame rate, please set `Window.onFrameRateSpeedUp` and/or `Window.onFrameRateCoolDown` to your own functions.
231+
The default logic is to reduce the frame rate when the screen is static, and change it back to 60 whenever the screen changes.
232+
If you would like to disable this behavior, please set `Window.onFrameRateSpeedUp` and `Window.onFrameRateCoolDown` to null function, i.e., () => {}.
233+
234+
Note that in Unity 2019.3 and above, UIWidgets will use OnDemandRenderAPI to implement this feature, which will greatly save the battery.
233235

234236
#### WebGL Canvas Device Pixel Ratio Plugin
235237
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
@@ -258,12 +260,34 @@ Unity, by default, resizes the width and height of an imported image to the near
258260
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.
259261

260262
#### Update Emoji
261-
UIWidgets supports rendering emoji in (editable) texts. The emoji images comes from the free
262-
resources provided by [Google Emoji](https://emojipedia.org/google). If you would
263-
like to use your own images for emoji, please update the texture image `Tests/Resources/Emoji.png`,
264-
and the unicode-index table in `Runtime/ui/txt/emoji.cs` which maps unicodes to specific locations
265-
in the texture. Specifically, remember to update the Dictionary `emojiLookupTable`, number of rows
266-
in the texture `rowCount`, and number of columns `colCount`.
263+
UIWidgets supports rendering emoji in (editable) texts.
264+
The default emoji resource version is [iOS 13.2](https://emojipedia.org/apple/ios-13.2).
265+
We also prepared the resources of [Google Emoji](https://emojipedia.org/google).
266+
To switch to Google version of emoji, please follow the following steps:
267+
268+
1. Copy `Runtime/Resources/backup~/EmojiGoogle.png` to `Runtime/Resources/images` folder.
269+
2. In the **Project** panel, find and select `EmojiGoogle` asset, and in the **Inspector** panel, change **Max Size** to 4096, and disable **Generate Mipmaps**.
270+
3. In the `OnEnable()` function in your class overriding `UIWidgetsPanel`, add the following code
271+
272+
```csharp
273+
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
274+
```
275+
276+
If you would like to use your own images for emoji, please follow the following steps:
277+
278+
1. Create the sprite sheet (take `EmojiGoogle.png` as an example), and put in a `Resources` folder in your project, (for example `Resources/myImages/MyEmoji.png`).
279+
2. In the `OnEnable()` function, add the following code (replace example values with actual value). Note that the order of emoji codes should be consistent with the sprite sheet.
280+
281+
```csharp
282+
EmojiUtils.configuration = new EmojiResourceConfiguration(
283+
spriteSheetAssetName: "myImage/MyEmoji",
284+
emojiCodes: new List<int> {
285+
0x1f004, 0x1f0cf, 0x1f170, ...
286+
},
287+
spriteSheetNumberOfRows: 36,
288+
spriteSheetNumberOfColumns: 37,
289+
);
290+
```
267291

268292
#### Interact with GameObject Drag&Drops
269293

@@ -273,8 +297,6 @@ in the texture `rowCount`, and number of columns `colCount`.
273297

274298
With the provided packaged stateful widget `UnityObjectDetector` and its `onRelease` callback function, you can easily drag some objects (for example GameObject from Hierarchy, files from Project Window, etc) into the area, get the UnityEngine.Object[] references and make further modification.
275299

276-
Please refer to "UIWidgetsTests -> Drag&Drop" for simple examples.
277-
278300

279301
## Debug UIWidgets Application
280302

@@ -288,20 +310,27 @@ The symbol is for debug purpose, please remove it from your release build.
288310
#### UIWidgets Inspector
289311
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
290312
via *Window/Analysis/UIWidgets* inspector in Editor menu.
313+
291314
**Note**
292315
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
293316
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
294317

295318
## Learn
296319

297320
#### Samples
298-
You can find many UIWidgets App samples in the UIWidgets package in the **Samples** folder.
299-
Feel free to try them out and make modifications to see the results.
300-
To get started, the UIWidgetsTheatre scene provides you
301-
a list of carefully selected samples to start with.
302-
303-
You can also try UIWidgets-based Editor windows by clicking **UIWidgetsTest** on the main menu
321+
You can find many UIWidgets sample projects on Github, which cover different aspects and provide you
322+
learning materials in various levels:
323+
* UIWidgetsSamples (https://github.com/UIWidgets/UIWidgetsSamples). These samples are developed by the dev team in order to illustrates all the features of
324+
UIWidgets. First clone this Repo to the **Assets** folder of your local UIWidgets project. Then
325+
you can find all the sample scenes under the **Scene** folder.
326+
You can also try UIWidgets-based Editor windows by clicking the new **UIWidgetsTests** tab on the main menu
304327
and open one of the dropdown samples.
328+
* awesome-UIWidgets by Liangxie (https://github.com/liangxiegame/awesome-uiwidgets). This Repo contains
329+
lots of UIWidget demo apps and third-party applications.
330+
* ConnectApp (https://github.com/UnityTech/ConnectAppCN). This is an online, open-source UIWidget-based App developed
331+
by the dev team. If you are making your own App with UIWidgets, this project will provides you with
332+
many best practice cases.
333+
305334

306335
#### Wiki
307336
The develop team is still working on the UIWidgets Wiki. However, since UIWidgets is mainly derived from Flutter,

0 commit comments

Comments
 (0)