浏览代码

Merge branch 'master' into zxw/devTools

/zxw-devTools
guanghuispark 3 年前
当前提交
9b5d28e8
共有 678 个文件被更改,包括 3362 次插入3165 次删除
  1. 5
      .yamato/upm-ci.yml
  2. 246
      README-ZH.md
  3. 276
      README.md
  4. 7
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
  5. 84
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity
  6. 17
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs
  7. 4
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/UIWidgetsEditorWindowSample.asmdef
  8. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs
  9. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs
  10. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs
  11. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs
  12. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs
  13. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs
  14. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs
  15. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
  16. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs
  17. 4
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NavigatorPopSample.cs
  18. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NetWorkImageSample.cs
  19. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
  20. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs
  21. 52
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity
  22. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs
  23. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs
  24. 2
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextFieldTest.cs
  25. 90
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs
  26. 28
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
  27. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_refresh_demo.cs
  28. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_segmented_control_demo.cs
  29. 239
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs
  30. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs
  31. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_demo.cs
  32. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs
  33. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/leave_behind_demo.cs
  34. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/overscroll_demo.cs
  35. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/text_form_field_demo.cs
  36. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs
  37. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/model/scoped_model.cs
  38. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs
  39. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs
  40. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  41. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs
  42. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs
  43. 3
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs
  44. 4
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs
  45. 2
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ExpansionPanelSample.cs
  46. 101
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs
  47. 4
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs
  48. 3
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs
  49. 3
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs
  50. 3
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs
  51. 4
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ToDoAppSample.cs
  52. 2
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/UIWidgetsSamplePanel.cs
  53. 2
      Samples/UIWidgetsSamples_2019_4/ProjectSettings/ProjectVersion.txt
  54. 3
      add_sample.sh
  55. 21
      com.unity.uiwidgets/CHANGELOG.md
  56. 144
      com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs
  57. 28
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  58. 2
      com.unity.uiwidgets/LICENSE.md
  59. 2
      com.unity.uiwidgets/Runtime/Plugins.meta
  60. 6
      com.unity.uiwidgets/Runtime/animation/animation_controller.cs
  61. 2
      com.unity.uiwidgets/Runtime/animation/tween_sequence.cs
  62. 267
      com.unity.uiwidgets/Runtime/async/timer.cs
  63. 2
      com.unity.uiwidgets/Runtime/cupertino/button.cs
  64. 2
      com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
  65. 2
      com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs
  66. 32
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  67. 2
      com.unity.uiwidgets/Runtime/cupertino/localization.cs
  68. 683
      com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
  69. 4
      com.unity.uiwidgets/Runtime/cupertino/refresh.cs
  70. 2
      com.unity.uiwidgets/Runtime/cupertino/route.cs
  71. 2
      com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
  72. 2
      com.unity.uiwidgets/Runtime/cupertino/slider.cs
  73. 2
      com.unity.uiwidgets/Runtime/cupertino/switch.cs
  74. 101
      com.unity.uiwidgets/Runtime/engine/DisplayMetrics.cs
  75. 23
      com.unity.uiwidgets/Runtime/engine/UIWidgetsMessageManager.cs
  76. 653
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs
  77. 4
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs.meta
  78. 5
      com.unity.uiwidgets/Runtime/external/SplayTree.cs
  79. 2
      com.unity.uiwidgets/Runtime/external/simplejson/SimpleJSON.cs
  80. 7
      com.unity.uiwidgets/Runtime/foundation/assertions.cs
  81. 4
      com.unity.uiwidgets/Runtime/foundation/basic_types.cs
  82. 2
      com.unity.uiwidgets/Runtime/foundation/binding.cs
  83. 21
      com.unity.uiwidgets/Runtime/foundation/collections.cs
  84. 110
      com.unity.uiwidgets/Runtime/foundation/debug.cs
  85. 19
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  86. 2
      com.unity.uiwidgets/Runtime/foundation/isolates.cs
  87. 2
      com.unity.uiwidgets/Runtime/foundation/synchronous_future.cs
  88. 6
      com.unity.uiwidgets/Runtime/gestures/binding.cs
  89. 26
      com.unity.uiwidgets/Runtime/gestures/events.cs
  90. 2
      com.unity.uiwidgets/Runtime/gestures/force_press.cs
  91. 5
      com.unity.uiwidgets/Runtime/gestures/hit_test.cs
  92. 2
      com.unity.uiwidgets/Runtime/gestures/multidrag.cs
  93. 2
      com.unity.uiwidgets/Runtime/gestures/multitap.cs
  94. 2
      com.unity.uiwidgets/Runtime/gestures/recognizer.cs
  95. 4
      com.unity.uiwidgets/Runtime/material/about.cs
  96. 103
      com.unity.uiwidgets/Runtime/material/animated_icons/animated_icons.cs
  97. 4
      com.unity.uiwidgets/Runtime/material/animated_icons/animated_icons_data.cs
  98. 992
      com.unity.uiwidgets/Runtime/material/animated_icons/data/add_event.g.cs
  99. 982
      com.unity.uiwidgets/Runtime/material/animated_icons/data/arrow_menu.g.cs
  100. 982
      com.unity.uiwidgets/Runtime/material/animated_icons/data/close_menu.g.cs

5
.yamato/upm-ci.yml


test_editors:
- version: 2018.4
- version: 2019.1
- version: 2019.2
- version: 2019.4
- version: 51fe52edbb02
test_platforms:
- name: win
type: Unity::VM

246
README-ZH.md


# UIWidgets
# UIWidgets 2.0 (preview)
## 介绍

UIWidgets主要来自[Flutter](https://github.com/flutter/flutter)。但UIWidgets通过使用强大的Unity引擎为开发人员提供了许多新功能,显著地改进他们开发的应用性能和工作流程。
UIWidgets 2.0是UIWidgets的最新版本,它主要着力于UI绘制相关的整体性能优化。经测试,UIWidgets 2.0在iPhone 6等部分机型上的帧率相对1.0版本可以取得10%左右的提升。如果因为各种原因您还需要使用UIWidgets 1.0,请在Releases中下载对应的包或者使用uiwidgets_1.0分支。
与任何其他Unity项目一样,UIWidgets应用可以直接部署在各种平台上,包括PC,移动设备和网页等。
与任何其他Unity项目一样,UIWidgets应用可以直接部署在各种平台上,包括PC和移动设备等。
#### 多媒体支持
除了基本的2D UI之外,开发人员还能够将3D模型,音频,粒子系统添加到UIWidgets应用中。

### 基于UIWidgets的项目
#### Unity Connect App
Unity Connect App是使用UIWidgets开发的一个移动App产品,您随时可以在Android (https://connect.unity.com/connectApp/download)
Unity Connect App是使用UIWidgets开发的一个移动App产品,您随时可以在Android (https://unity.cn/connectApp/download)
以及iOS (Searching for "Unity Connect" in App Store)端下载到它最新的版本. 本项目的所有代码均开源@https://github.com/UnityTech/ConnectAppCN.
#### Unity中文官方文档

#### Unity
安装 **Unity 2018.4.10f1(LTS)****Unity 2019.1.14f1** 及其更高版本。 你可以从[https://unity3d.com/get-unity/download](https://unity3d.com/get-unity/download)下载最新的Unity。
UIWidgets的各个版本所需的Unity版本如下表所示。您可以从[https://unity3d.com/get-unity/download](https://unity3d.com/get-unity/download)下载最新的Unity。
| UIWidgets 版本 | Unity 2019 LTS | Unity 2020 LTS |
| -----------------------------------------------| ------------------------- | ------------------------- |
| 1.5.4 及以下 | 2019.4.10f1 及以上 | N\A |
| 2.0.1 | 2019.4.26f1c1 | N\A |
| 2.0.2 及以上 | 2019.4.26f1c1 及以上 | N\A |
访问我们的Github存储库 [https://github.com/UnityTech/UIWidgets](https://github.com/UnityTech/UIWidgets)下载最新的UIWidgets包。
访问我们的Github存储库 [https://github.com/Unity-Technologies/com.unity.uiwidgets](https://github.com/Unity-Technologies/com.unity.uiwidgets)下载最新的UIWidgets包。
将下载的包文件夹移动到Unity项目的Package文件夹中。

cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
cd <YourPackagePath>
git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgets
在unity的PackageManager中,选择添加添加local file。选中```/com.unity.uiwidgets```下的```package.json```。
#### 运行环境
UIWidgets目前暂时只支持MacOS(Metal),iOS(Metal),Android(Armv7,OpenGLes)以及 Windows(Direct3D11)。我们后续会针对更广泛的运行环境进行适配,敬请期待。
## 入门指南

首先,请打开或创建Unity项目并使用Unity编辑器打开它。
然后打开Project Settings,转到Player部分并**将“UIWidgets_DEBUG”添加到Scripting Define Symbols字段中。**
这样就启动了UIWidgets的调试模式。 在之后发布版本的时候清空这个字段。
#### 二、 场景构建

UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建应用程序并在Unity编辑器中播放。
1. 创建一个新C#脚本,命名为“UIWidgetsExample.cs”,并将以下代码粘贴到其中。
```csharp
```csharp
using Unity.UIWidgets.animation;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class UIWidgetsExample : UIWidgetsPanel {
protected override void OnEnable() {
namespace UIWidgetsSample
{
public class CountDemo : UIWidgetsPanel
{
protected void OnEnable()
{
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// a TextStyle object
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontStyle.italic);
// add material icons, familyName must be "Material Icons"
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
// AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) => builder(context)
)
);
protected override void main()
{
ui_.runApp(new MyApp());
class ExampleApp : StatefulWidget {
public ExampleApp(Key key = null) : base(key) {
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new CounterApp()
);
}
}
public override State createState() {
return new ExampleState();
}
internal class CounterApp : StatefulWidget
{
public override State createState()
{
return new CountDemoState();
}
class ExampleState : State<ExampleApp> {
int counter = 0;
internal class CountDemoState : State<CounterApp>
{
private int count = 0;
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {
new Text("Counter: " + this.counter),
new GestureDetector(
onTap: () => {
this.setState(() => {
this.counter++;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.fromARGB(255, 255, 0, 0),
child: new Column(children: new List<Widget>()
{
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{
setState(() =>
{
count++;
padding: EdgeInsets.symmetric(20, 20),
color: Colors.blue,
child: new Text("Click Me")
color: Color.fromARGB(255,0 , 255, 0),
width: 100,
height: 40
)
),
);
}
)
);
```
```
2. 保存此脚本,并将其附加到Panel 1中作为其组件。
3. 在Unity编辑器中,点击Play按钮来启动应用。

2. 选择目标平台,点击Build。 之后Unity编辑器将自动组装所有相关资源并生成最终的应用程序包。
#### 五、如何加载图像?
1. 将你的图像文件,如image1.png,放在Resources文件夹中。
2. 你可以在同一文件夹中添加image1@2.png和image1@3.png以支持高清屏幕显示。
3. 使用Image.asset(“image1”)加载图像。 注意:因为是在Unity中,所以不需要添加.png后缀。
1. 将你的图像文件,如image1.png,放在StreamingAssets文件夹中。
2. 使用Image.file("image1.png")加载图像。
1. 假设你有一个loading1.gif文件,将其重命名为loading1.gif.bytes并复制到Resources文件夹。
2. 你可以在同一文件夹中添加loading1@2.gif.bytes和loading1@3.gif.bytes以支持高清屏幕显示。
3. 使用Image.asset(“loading1.gif”)加载gif图像。
1. 假设你有一个loading1.gif文件,复制到StreamingAssets文件夹。
2. 使用Image.file("loading1.gif")加载gif图像。
如果您希望在您的UIWidgets App中显示状态栏,您可以使用这个[解决方案](https://github.com/Over17/UnityShowAndroidStatusBar)。我们将尽快推出我们自己的解决方案,并保证届时开发者可以进行无缝切换。
如果您希望在您的UIWidgets App中显示状态栏,您可以取消```Start in fullscreen``` 与 ```record outside safe area```, 确认```UIWidgetsAndroidConfiguration```下```showStatusBar```为 ```true```
此外,为了让上述插件在Android P及以上Android系统中正常工作,请勾选上"Player Settings"中的"Render Outside Safe Area"选项。
#### 七、图片导入设置
请将图片放入StreamingAssets下,而后用```Image.file```读取
#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低,在界面变动时再将帧率提高至60。
如果您不想开启该功能,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为空函数,()=> {}即可。
#### 八、移动设备优化
目前在默认情况下,为了保证流畅度,项目在各个平台上均会以最高的刷新频率运行。不过您可以通过在代码中设置```UIWidgetsGlobalConfiguration.EnableAutoAdjustFramerate = true```的方式来开启自动降帧的功能:该功能开启后,在UI内容不变的情况下我们将降低项目的刷新率来降低耗电。
在Unity 2019.3版本及以上,UIWidgets将使用OnDemandRenderAPI来实现帧率调节,它将在不影响UI响应速度的情况下大幅降低耗电和发热问题。
在移动设备上UI绘制的流畅度受到GC影响较大。项目默认会开启OnDemandGC来接管并优化整体GC效果。如果您不需要GC被UIWidgets控制,请在代码中设置```UIWidgetsGlobalConfiguration.EnableIncrementalGC = false```。
#### 八、WebGL Canvas分辨率调整插件
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib`(目前有2018.3和2019.1)解决了这个问题。
请根据您的项目的Unity版本选择对应的插件,并禁用此插件的其他版本。方法如下:在Project面板中选中该插件,在Inspector面板中的Select platforms for plugin中,去掉WebGL后面的对勾。
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
此插件覆盖了Unity WebGL构建模块中的如下参数:
```none
JS_SystemInfo_GetWidth
JS_SystemInfo_GetHeight
JS_SystemInfo_GetCurrentCanvasWidth
JS_SystemInfo_GetCurrentCanvasHeight
$Browser
$JSEvents
```
如果您需要实现自己的WebGL插件,并且您的插件覆盖了这些参数中的至少一种,您需要采用上文中提到的方法禁用`UIWidgetsCanvasDevicePixelRatio`插件,以防止可能的冲突。
如果您仍然需要此插件所提供的功能,您可以手动将此插件对Unity WebGL构建模块的修改应用到您的插件中。
`UIWidgetsCanvasDevicePixelRatio`插件中所有的修改之处都以`////////// Modification Start ////////////`和`////////// Modification End ////////////`标识。
在被标识的代码中,所有乘/除以`devicePixelRatio`都来自于我们的修改。
若您需要详细了解此插件所修改的脚本,请参考您的Unity Editor安装目录下的`PlaybackEngines/WebGLSupport/BuildTools/lib`文件夹中的`SystemInfo.js`和`UnityNativeJS/UnityNative.js`。
## 调试UIWidgets应用程序
#### 九、图片导入设置
默认情况下,Unity会将导入图片的宽和高放缩为最近的等于2的幂的整数。
在UIWidgets中使用图片时,记得将这一特性关闭,以免图片被意外放缩,方法如下:在Project面板中选中图片,在"Inspector"面板中将"Non Power of 2"(在"Advanced"中)设置为"None"。
在编辑器菜单栏选择```UIWidgets->EnableDebug```
#### 十、更新表情(Emoji)
UIWidgets支持渲染文本中包含的表情。
默认的表情资源为[iOS 13.2](https://emojipedia.org/apple/ios-13.2)。
我们也准备了[Google Emoji](https://emojipedia.org/google)的表情资源。
如果您希望切换到Google版本的表情,请按如下步骤操作:
如果想在runtime开启debug模式,请在项目代码中设置```UIWidgetsGlobalConfiguration.EnableDebugAtRuntime = true```。在默认情况下debug模式为关闭状态。
1. 拷贝`Runtime/Resources/backup~/EmojiGoogle.png`到`Runtime/Resources/images`目录。
2. 在**Project**面板中,找到`EmojiGoogle`资源,在**Inspector**面板中,将**Max Size**更改为4096,取消选中**Generate Mipmaps**,并选中**Alpha Is Transparency**。
3. 在您的代码中继承`UIWidgetsPanel`的类的`OnEnable()`函数中,添加如下代码
## 使用Window Scope保护外部调用
如果您在调试时遇到 `AssertionError: Window.instance is null` 或者在调用 `Window.instance` 时得到空指针, 那么您需要
使用以下方式来保护您的调用,使之可以在正确的Isolate上执行回调逻辑:
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
using(Isolate.getScope(the isolate of your App)) {
// code dealing with UIWidgets,
// e.g. setState(() => {....})
}
如果您希望使用自己的表情图片,请按如下步骤操作:
1. 参照`EmojiGoogle.png`,创建您自己的Emoji表单,并放到工程目录下的某个`Resources`目录中,例如`Resources/myImages/MyEmoji.png`)。
2. 在`OnEnable()`函数中,添加如下代码(记得将示例的值改为真实的值)。注意Emoji的编码的顺序要和Emoji表单一致。
```csharp
EmojiUtils.configuration = new EmojiResourceConfiguration(
spriteSheetAssetName: "myImage/MyEmoji",
emojiCodes: new List<int> {
0x1f004, 0x1f0cf, 0x1f170, ...
},
spriteSheetNumberOfRows: 36,
spriteSheetNumberOfColumns: 37,
);
```
#### 十一、与GameObject进行拖拽交互
<p align="center">
<img src="https://connect-prd-cdn.unity.com/20190718/p/images/e3c9cf9b-c732-4eb2-9afd-fe7de894f342_Custom_Inspector_Showcase_320px.gif" width="300"/>
</p>
我们提供了一个包装好的`UnityObjectDetector`组件以及`onRelease`回调函数,借此您可以实现简单地将物体(例如Hierarchy内的场景物体、Project窗口下的文件等)拖拽至区域内,来获得`UnityEngine.Object[] `类型的引用并进行操作。
## 调试UIWidgets应用程序
#### 定义UIWidgets_DEBUG
我们建议在Unity编辑器中定义 UIWidgets_DEBUG 脚本符号,这将打开UIWidgets中的调试断言(debug assertion),有助于更早发现潜在的Bug。
因此选择 **Player Settings** > **Other Settings** > **Configuration** > **Scripting Define Symbols** ,并添加 UIWidgets_DEBUG。
该符号仅供调试使用,请在发布版本中删除它。
#### UIWidgets Inspector
UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以在Unity编辑器的**Window** > **Analysis** > **UIWidget Inspector** 中的找到它。
注意
- 需要定义 UIWidgets_DEBUG 使inspector正常工作。
- Inspector目前仅适用于编辑器的播放模式,目前不支持独立版本的应用程序。
通常,在您使用外部事件,例如来自UIWidgets之外的输入事件、网络传输回调事件时需要做这样的处理。具体的您可以参考我们的 HttpRequestSample 这个样例中的写法。需要注意的是,一般情况下您在UIWidgets框架的内部调用 (如 `Widget.build, State.initState...`)中不需要额外采取上述保护措施。
## 学习

- UIWidgets官方示例。目前所有官方使用的示例项目均维护在一个独立的Github仓库( https://github.com/UIWidgets/UIWidgetsSamples )中。你可以
将它clone到你项目本地的Assets目录下使用。
- UIWidgets官方示例。目前所有官方使用的示例项目均维护在一个独立的Github仓库( https://github.com/Unity-Technologies/com.unity.uiwidgets )中。
具体的,你可以在Sample项目的**Scene**子文件夹中浏览所有示例UI场景。
此外,你还可以点击主菜单上的新增的UIWidgetsTests选项卡,并在下拉菜单中选择一个EditorWindow UI示例来运行。
- UIWidgets凉鞋系列教程。你可以在凉鞋老师整理的Github仓库( https://github.com/liangxiegame/awesome-uiwidgets )中学习UIWidgets的基本用法

276
README.md


# UIWidgets
# UIWidgets 2.0 (preview)
[中文](README-ZH.md)

the powerful Unity Engine, it offers developers many new features to improve their Apps
as well as the develop workflow significantly.
As the latest version, UIWidgets 2.0 aims to optimize the overall performance of the package. Specifically, a performance gain around 10% is observed on mobile devices like iPhone 6 after upgrading to UIWidgets 2.0. However, if you still want to use the original UIWidgets 1.0, please download the archived packages from Releases or switch your working branch to uiwidgets_1.0.
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 and mobile devices directly, like
any other Unity projects.
#### Multimedia Support

### Projects using UIWidgets
#### Unity Connect App
The Unity Connect App is created using UIWidgets and available for both Android (https://connect.unity.com/connectApp/download)
The Unity Connect App is created using UIWidgets and available for both Android (https://unity.cn/connectApp/download)
and iOS (Searching for "Unity Connect" in App Store). This project is open-sourced @https://github.com/UnityTech/ConnectAppCN.
#### Unity Chinese Doc

#### Unity
Install **Unity 2018.4.10f1 (LTS)** or **Unity 2019.1.14f1** and above. You can download the latest Unity on https://unity3d.com/get-unity/download.
The compatible Unity versions for each UIWidgets release are listed below. You can download the latest Unity on https://unity3d.com/get-unity/download.
| UIWidgets version | Unity 2019 LTS | Unity 2020 LTS |
| -----------------------------------------------| ------------------------- | ------------------------- |
| 1.5.4 and below | 2019.4.10f1 and above | N\A |
| 2.0.1 | 2019.4.26f1c1 | N\A |
| 2.0.2 and above | 2019.4.26f1c1 and above | N\A |
Visit our Github repository https://github.com/UnityTech/UIWidgets
Visit our Github repository https://github.com/Unity-Technologies/com.unity.uiwidgets
to download the latest UIWidgets package.
Move the downloaded package folder into the **Package** folder of your Unity project.

```none
cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
cd <YourPackagePath>
git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgets
In PackageManger of unity, select add local file. select ```package.json``` under ```/com.unity.uiwidgets```
#### Runtime Environment
Currently UIWidgets only supports MacOS(Metal), iOS(Metal), Android(Armv7, OpenGLes) and Windows(Direct3D11). More devices will be supported in the future.
## Getting Start
#### i. Overview

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.
#### ii. Scene Build
A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a

1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it.
```csharp
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class UIWidgetsExample : UIWidgetsPanel {
protected override void OnEnable() {
namespace UIWidgetsSample
{
public class CountDemo : UIWidgetsPanel
{
protected void OnEnable()
{
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// a TextStyle object
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontStyle.italic);
// add material icons, familyName must be "Material Icons"
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
// AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) => builder(context)
)
);
protected override void main()
{
ui_.runApp(new MyApp());
class ExampleApp : StatefulWidget {
public ExampleApp(Key key = null) : base(key) {
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new CounterApp()
);
}
}
public override State createState() {
return new ExampleState();
}
internal class CounterApp : StatefulWidget
{
public override State createState()
{
return new CountDemoState();
}
class ExampleState : State<ExampleApp> {
int counter = 0;
internal class CountDemoState : State<CounterApp>
{
private int count = 0;
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {
new Text("Counter: " + this.counter),
new GestureDetector(
onTap: () => {
this.setState(()
=> {
this.counter++;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.fromARGB(255, 255, 0, 0),
child: new Column(children: new List<Widget>()
{
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{
setState(() =>
{
count++;
padding: EdgeInsets.symmetric(20, 20),
color: Colors.blue,
child: new Text("Click Me")
color: Color.fromARGB(255,0 , 255, 0),
width: 100,
height: 40
)
),
);
}
)
);
}
}
}

all relevant resources and generate the final App package.
#### How to load images?
1. Put your images files in Resources folder. e.g. image1.png.
2. You can add image1@2.png and image1@3.png in the same folder to support HD screens.
3. Use Image.asset("image1") to load the image. Note: as in Unity, ".png" is not needed.
1. Put your images files in StreamingAssets folder. e.g. image1.png.
2. Use Image.file("image1.png") to load the image.
1. Suppose you have loading1.gif. Rename it to loading1.gif.bytes and copy it to Resources folder.
2. You can add loading1@2.gif.bytes and loading1@3.gif.bytes in the same folder to support HD screens.
3. Use Image.asset("loading1.gif") to load the gif images.
1. Put your gif files in StreamingAssets folder. e.g. loading1.gif.
2. Use Image.file("loading1.gif") to load the gif images.
#### Show Status Bar on Android
Status bar is always hidden by default when an Unity project is running on an Android device.
If you
want to show the status bar in your App, you can disable```Start in fullscreen``` and ```record outside safe area```, make sure ```showStatusBar``` is ```true``` under ```UIWidgetsAndroidConfiguration```
#### Image Import Setting
Please put images under StreamingAssets folder, a and loading it using ```Image.file```.
#### Performance Optimization on Mobile devices
By setting ```UIWidgetsGlobalConfiguration.EnableAutoAdjustFramerate = true``` in your project, UIWidgets will drop the frame rate of your App to 0 if the UI contents of UIWidgetsPanel is not changed for some time. This will help to prevent battery drain on mobile devices significantly. Note that this feature is disabled by default.
Long time garbage collection may cause App to stuck frequently. In UIWidgets we enable incremental garbage collection to avoid it. However, you can disable this feature by setting ```UIWidgetsGlobalConfiguration.EnableIncrementalGC = false```.
## Debug UIWidgets Application
In Unity editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
You can also enable debug mode in runtime by setting ```UIWidgetsGlobalConfiguration.EnableDebugAtRuntime = true``` in your project. Note that this value is set to false by default.
#### Using Window Scope
## Using Window Scope
using(WindowProvider.of(your gameObject with UIWidgetsPanel).getScope()) {
using(Isolate.getScope(the isolate of your App)) {
// code dealing with UIWidgets,
// e.g. setState(() => {....})
}

not invoked by UIWidgets. For example, if the code is in `completed` callback of `UnityWebRequest`,
you need to enclose them with window scope.
Please see [HttpRequestSample](./Samples/UIWidgetSample/HttpRequestSample.cs) for detail.
Please see our HttpRequestSample for detail.
#### Show Status Bar on Android
Status bar is always hidden by default when an Unity project is running on an Android device. If you
want to show the status bar in your App, this
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
compatible to UIWidgets, therefore can be used as a good option before we release our
full support solution on this issue.
Besides,
please set "Render Outside Safe Area" to true in the "Player Settings" to make this plugin working properly on Android P or later.
#### Automatically Adjust Frame Rate
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".
The default logic is to reduce the frame rate when the screen is static, and change it back to 60 whenever the screen changes.
If you would like to disable this behavior, please set `Window.onFrameRateSpeedUp` and `Window.onFrameRateCoolDown` to null function, i.e., () => {}.
Note that in Unity 2019.3 and above, UIWidgets will use OnDemandRenderAPI to implement this feature, which will greatly save the battery.
#### WebGL Canvas Device Pixel Ratio Plugin
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
Therefore, the image may blur in the builded WebGL program.
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib` (2018.3 and 2019.1 for now) solves this issue.
Please select the plugin of the Unity version corresponding to your project, and disable other versions of this plugin, as follows: select this plugin in the **Project** panel, and uncheck **WebGL** under **Select platforms for plugin** in the **Inspector** panel.
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
JS_SystemInfo_GetCurrentCanvasHeight
$Browser
$JSEvents
```
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.
To learn about the original script in detail, please refer to `SystemInfo.js` and `UnityNativeJS/UnityNative.js` in `PlaybackEngines/WebGLSupport/BuildTools/lib` in your Unity Editor installation.
#### Image Import Setting
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.
#### Update Emoji
UIWidgets supports rendering emoji in (editable) texts.
The default emoji resource version is [iOS 13.2](https://emojipedia.org/apple/ios-13.2).
We also prepared the resources of [Google Emoji](https://emojipedia.org/google).
To switch to Google version of emoji, please follow the following steps:
1. Copy `Runtime/Resources/backup~/EmojiGoogle.png` to `Runtime/Resources/images` folder.
2. In the **Project** panel, find and select `EmojiGoogle` asset, and in the **Inspector** panel, change **Max Size** to 4096, disable **Generate Mipmaps**, and enable **Alpha Is Transparency**.
3. In the `OnEnable()` function in your class overriding `UIWidgetsPanel`, add the following code
```csharp
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
```
If you would like to use your own images for emoji, please follow the following steps:
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`).
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.
```csharp
EmojiUtils.configuration = new EmojiResourceConfiguration(
spriteSheetAssetName: "myImage/MyEmoji",
emojiCodes: new List<int> {
0x1f004, 0x1f0cf, 0x1f170, ...
},
spriteSheetNumberOfRows: 36,
spriteSheetNumberOfColumns: 37,
);
```
#### Interact with GameObject Drag&Drops
<p align="center">
<img src="https://connect-prd-cdn.unity.com/20190718/p/images/e3c9cf9b-c732-4eb2-9afd-fe7de894f342_Custom_Inspector_Showcase_320px.gif" width="300"/>
</p>
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.
## Debug UIWidgets Application
#### Define UIWidgets_DEBUG
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this:
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
and add **UIWidgets_DEBUG**.
The symbol is for debug purpose, please remove it from your release build.
#### UIWidgets Inspector
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
via *Window/Analysis/UIWidgets* inspector in Editor menu.
**Note**
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
* UIWidgetsSamples (https://github.com/UIWidgets/UIWidgetsSamples). These samples are developed by the dev team in order to illustrates all the features of
UIWidgets. First clone this Repo to the **Assets** folder of your local UIWidgets project. Then
* UIWidgetsSamples (https://github.com/Unity-Technologies/com.unity.uiwidgets). These samples are developed by the dev team in order to illustrates all the features of
UIWidgets.
you can find all the sample scenes under the **Scene** folder.
You can also try UIWidgets-based Editor windows by clicking the new **UIWidgetsTests** tab on the main menu
and open one of the dropdown samples.

7
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using UnityEngine.UI;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

child: new Column(children: new List<Widget>()
{
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new Icon(CupertinoIcons.battery_charging, color: Colors.yellow),
new Text($"count: {count}", style: new TextStyle(fontFamily: "CupertixnoIcons", color: Color.fromARGB(255, 0 ,0 ,255))),
new Text($"count: {count}", style: new TextStyle(fontFamily: "CupertinoIcons", color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{

84
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity


m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!28 &1096042013
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
--- !u!1 &1344837310
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 1777874941}
- component: {fileID: 1777874942}
- component: {fileID: 1777874943}
- component: {fileID: 1777874944}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged

m_Father: {fileID: 314921623}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_SizeDelta: {x: 500, y: 500}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1777874942
CanvasRenderer:

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777874940}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0817e3443c80cb943a03dcf7b120bd2e, type: 3}
m_Name:

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!114 &1777874944
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777874940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0817e3443c80cb943a03dcf7b120bd2e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 1096042013}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
fonts:
- family: CupertinoIcons
fonts:
- asset: CupertinoIcons.ttf
weight: 0

17
Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
using ui_ = Unity.UIWidgets.widgets.ui_;
using UnityEngine;
[MenuItem("UIWidgets/EditorSample")]
[MenuItem("UIWidgets/EditorSample/GalleryMain")]
protected override void onEnable()
{
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
AddFont("CupertinoIcons", new List<string> {"CupertinoIcons.ttf"}, new List<int> {0});
AddFont("GalleryIcons", new List<string> {"gallery/GalleryIcons.ttf"}, new List<int> {0});
}
protected override void main()
{
ui_.runApp(new GalleryApp());

4
Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/UIWidgetsEditorWindowSample.asmdef


"UIWidgetsGallery"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs


using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs


using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

4
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NavigatorPopSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NetWorkImageSample.cs


using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

52
Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity


m_GameObject: {fileID: 847097468}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b7e1083a82b756840b36958a76a3e6f3, type: 3}
m_Script: {fileID: 11500000, guid: 9c5c86936ca864ae684720ddcd50d759, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_Texture: {fileID: 945944095}
m_UVRect:
serializedVersion: 2
x: 0

fonts:
- family: CupertinoIcons
fonts:
- asset: CupertinoIcons.ttf
weight: 0
fonts: []
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 847097468}
m_CullTransparentMesh: 0
--- !u!28 &945944095
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
--- !u!1 &1548023132
GameObject:
m_ObjectHideFlags: 0

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

{
return new WidgetsApp(
home: new ExampleApp(),
color: Color.white,
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

2
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextFieldTest.cs


using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;

90
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using Brightness = Unity.UIWidgets.ui.Brightness;
using UnityEngine;
using System;
using uiwidgets;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using UnityEngine.Networking;
using Transform = Unity.UIWidgets.widgets.Transform;
namespace UIWidgetsSample
{

{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget {
public override Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: "Flutter Demo",
home: new Scaffold(
appBar: new AppBar(title: new Text("good")),
body: new Center(
child: new MyStatefulWidget()
)
)
);
}
}
class MyStatefulWidget : StatefulWidget {
public MyStatefulWidget(Key key = null) : base(key: key)
{
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new HomeScreen() //new DetailScreen1("ok")
//color: Color.white
);
}
public override State createState() => new _MyStatefulWidgetState();
class _MyStatefulWidgetState : State<MyStatefulWidget> {
Color textColor = Colors.blue;
int _enterCounter = 0;
int _exitCounter = 0;
float x = 0.0f;
float y = 0.0f;
void _incrementEnter(PointerEvent details) {
UnityEngine.Debug.Log("enter");
setState(() =>{
_enterCounter++;
});
}
void _incrementExit(PointerEvent details) {
setState(() =>{
textColor = Colors.blue;
_exitCounter++;
});
}
void _updateLocation(PointerEvent details) {
setState(() =>{
textColor = Colors.red;
x = details.position.dx;
y = details.position.dy;
});
}
public override Widget build(BuildContext context) {
return new MouseRegion(
onEnter: _incrementEnter,
onHover: _updateLocation,
onExit: _incrementExit,
child: new FlatButton(
color: Colors.white,
textColor: Colors.teal[700], //when hovered text color change
shape: new RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
side: new BorderSide(
color: Colors.teal[700]
)
),
onPressed: () => { },
child: new Text("Log in", style: new TextStyle(color: textColor))
)
);
}
}
class HomeScreen : StatelessWidget
{

28
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery {
public class GalleryMain : UIWidgetsPanel {
protected override void main() {
namespace UIWidgetsGallery
{
public class GalleryMain : UIWidgetsPanel
{
protected new void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
protected new void OnEnable() {
base.OnEnable();
protected override void onEnable()
{
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
AddFont("CupertinoIcons", new List<string> {"CupertinoIcons.ttf"}, new List<int> {0});
AddFont("GalleryIcons", new List<string> {"gallery/GalleryIcons.ttf"}, new List<int> {0});
}
}

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_refresh_demo.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_segmented_control_demo.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

239
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs


internal class _BottomAppBarDemoState : State<BottomAppBarDemo>
{
private static GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
private static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
// FAB shape

value: FloatingActionButtonLocation.centerFloat
);
private static void _showSnackbar()
{
string text =
"When the Scaffold\"s floating action button location changes, " +
"the floating action button animates to its new position. " +
"The BottomAppBar adapts its shape appropriately.";
_scaffoldKey.currentState.showSnackBar(
new SnackBar(content: new Text(text))
);
}
private static List<_NamedColor> kBabColors = new List<_NamedColor>
private static readonly List<_NamedColor> kBabColors = new List<_NamedColor>
{
new _NamedColor(null, "Clear"),
new _NamedColor(new Color(0xFFFFC100), "Orange"),

new _NamedColor(new Color(0xFF009BEE), "Blue"),
new _NamedColor(new Color(0xFF009BEE), "Blue")
private Color _babColor = kBabColors.First().color;
private _ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked;
private _ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked;
private Color _babColor = kBabColors.First().color;
private static void _showSnackbar()
{
var text =
"When the Scaffold\"s floating action button location changes, " +
"the floating action button animates to its new position. " +
"The BottomAppBar adapts its shape appropriately.";
_scaffoldKey.currentState.showSnackBar(
new SnackBar(content: new Text(text))
);
}
this.setState(() => { this._showNotch = value; });
setState(() => { _showNotch = value; });
this.setState(() => { this._fabShape = value; });
setState(() => { _fabShape = value; });
this.setState(() => { this._fabLocation = value; });
setState(() => { _fabLocation = value; });
this.setState(() => { this._babColor = value; });
setState(() => { _babColor = value; });
key: _scaffoldKey,
appBar: new AppBar(
_scaffoldKey,
new AppBar(
title: new Text("Bottom app bar"),
elevation: 0.0f,
actions: new List<Widget>

icon: new Icon(Icons.sentiment_very_satisfied),
onPressed: () =>
{
this.setState(() =>
{
this._fabShape = this._fabShape == kCircularFab ? kDiamondFab : kCircularFab;
});
setState(() => { _fabShape = _fabShape == kCircularFab ? kDiamondFab : kCircularFab; });
body: new Scrollbar(
new Scrollbar(
child: new ListView(
padding: EdgeInsets.only(bottom: 88.0f),
children: new List<Widget>

new _RadioItem<Widget>(kCircularFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kDiamondFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kNoFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kCircularFab, _fabShape, _onFabShapeChanged),
new _RadioItem<Widget>(kDiamondFab, _fabShape, _onFabShapeChanged),
new _RadioItem<Widget>(kNoFab, _fabShape, _onFabShapeChanged),
new _RadioItem<bool>(kShowNotchTrue, this._showNotch, this._onShowNotchChanged),
new _RadioItem<bool>(kShowNotchFalse, this._showNotch, this._onShowNotchChanged),
new _RadioItem<bool>(kShowNotchTrue, _showNotch, _onShowNotchChanged),
new _RadioItem<bool>(kShowNotchFalse, _showNotch, _onShowNotchChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndDocked, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndFloat, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndDocked, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndFloat, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, _fabLocation,
_onFabLocationChanged),
new _ColorsItem(kBabColors, this._babColor, this._onBabColorChanged)
new _ColorsItem(kBabColors, _babColor, _onBabColorChanged)
floatingActionButton: this._fabShape.value,
floatingActionButtonLocation: this._fabLocation.value,
_fabShape.value,
_fabLocation.value,
color: this._babColor,
fabLocation: this._fabLocation.value,
shape: this._selectNotch()
_babColor,
_fabLocation.value,
_selectNotch()
)
);
}

if (!this._showNotch.value)
if (!_showNotch.value)
if (this._fabShape == kCircularFab)
if (_fabShape == kCircularFab)
if (this._fabShape == kDiamondFab)
if (_fabShape == kDiamondFab)
return new _DiamondNotchedRectangle();
return null;
}

{
public readonly string label; // For the Semantics widget that contains title
public readonly string title;
public readonly T value;
public _ChoiceValue(T value, string title, string label)
{
this.value = value;

public readonly T value;
public readonly string title;
public readonly string label; // For the Semantics widget that contains title
return $"{this.GetType()}(\"{this.title}\")";
return $"{GetType()}(\"{title}\")";
public readonly _ChoiceValue<T> groupValue;
public readonly ValueChanged<_ChoiceValue<T>> onChanged;
public readonly _ChoiceValue<T> value;
public _RadioItem(_ChoiceValue<T> value, _ChoiceValue<T> groupValue, ValueChanged<_ChoiceValue<T>> onChanged)
{
this.value = value;

public readonly _ChoiceValue<T> value;
public readonly _ChoiceValue<T> groupValue;
public readonly ValueChanged<_ChoiceValue<T>> onChanged;
ThemeData theme = Theme.of(context);
var theme = Theme.of(context);
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: const EdgeInsetsDirectional.only(start: 16.0),
padding: EdgeInsets.only(left: 16.0f),
padding: EdgeInsetsDirectional.only(16.0f),
value: this.value,
groupValue: this.groupValue,
onChanged: this.onChanged
value: value,
groupValue: groupValue,
onChanged: onChanged
onTap: () =>
{
this.onChanged(this.value);
},
child: new Text(this.value.title,
onTap: () => { onChanged(value); },
child: new Text(value.title,
style: theme.textTheme.subtitle1
)
)

internal class _NamedColor
{
public readonly Color color;
public readonly string name;
public readonly Color color;
public readonly string name;
public readonly List<_NamedColor> colors;
public readonly ValueChanged<Color> onChanged;
public readonly Color selectedColor;
public _ColorsItem(List<_NamedColor> colors, Color selectedColor, ValueChanged<Color> onChanged)
{
this.colors = colors;

public readonly List<_NamedColor> colors;
public readonly Color selectedColor;
public readonly ValueChanged<Color> onChanged;
children: this.colors.Select<_NamedColor, Widget>((_NamedColor namedColor) =>
children: colors.Select<_NamedColor, Widget>(namedColor =>
onPressed: () => { this.onChanged(namedColor.color); },
onPressed: () => { onChanged(namedColor.color); },
width: 32.0f,
height: 32.0f
32.0f,
32.0f
side: new BorderSide(
color: namedColor.color == this.selectedColor ? Colors.black : new Color(0xFFD5D7DA),
width: 2.0f
new BorderSide(
namedColor.color == selectedColor ? Colors.black : new Color(0xFFD5D7DA),
2.0f
)
),
child: new Container(

internal class _Heading : StatelessWidget
{
public readonly string text;
public readonly string text;
ThemeData theme = Theme.of(context);
var theme = Theme.of(context);
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(start: 56.0),
padding: EdgeInsets.only(left: 56.0f),
padding: EdgeInsetsDirectional.only(56.0f),
child: new Text(this.text,
child: new Text(text,
style: theme.textTheme.bodyText2.copyWith(
color: theme.primaryColor
)

internal class _DemoBottomAppBar : StatelessWidget
{
private static readonly List<FloatingActionButtonLocation> kCenterLocations =
new List<FloatingActionButtonLocation>
{
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerFloat
};
public readonly Color color;
public readonly FloatingActionButtonLocation fabLocation;
public readonly NotchedShape shape;
public _DemoBottomAppBar(
Color color = null,
FloatingActionButtonLocation fabLocation = null,

this.shape = shape;
}
public readonly Color color;
public readonly FloatingActionButtonLocation fabLocation;
public readonly NotchedShape shape;
private static readonly List<FloatingActionButtonLocation> kCenterLocations =
new List<FloatingActionButtonLocation>
{
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerFloat
};
public override Widget build(BuildContext context)
{

onPressed: () =>
{
material_.showModalBottomSheet<object>(
context: context,
builder: (BuildContext subContext) => new _DemoDrawer()
context,
subContext => new _DemoDrawer()
if (kCenterLocations.Contains(this.fabLocation)) children.Add(new Expanded(child: new SizedBox()));
if (kCenterLocations.Contains(fabLocation)) children.Add(new Expanded(child: new SizedBox()));
children.Add(
new IconButton(

return new BottomAppBar(
color: this.color,
shape: this.shape,
color: color,
shape: shape,
child: new Row(children: children)
);
}

{
public _DemoDrawer()
{
}
public override Widget build(BuildContext context)
{
return new Drawer(

internal class _DiamondFab : StatelessWidget
{
public readonly Widget child;
public readonly VoidCallback onPressed;
public _DiamondFab(
Widget child = null,
VoidCallback onPressed = null

this.onPressed = onPressed;
}
public readonly Widget child;
public readonly VoidCallback onPressed;
public override Widget build(BuildContext context)
{
return new Material(

onTap: () => this.onPressed?.Invoke(),
onTap: () => onPressed?.Invoke(),
data: new IconThemeData(color: Theme.of(context).accentIconTheme.color),
child: this.child
data: new IconThemeData(Theme.of(context).accentIconTheme.color),
child: child
)
)
),

internal class _DiamondNotchedRectangle : NotchedShape
{
public _DiamondNotchedRectangle()
{
}
public override Path getOuterPath(Rect host, Rect guest)
{
//there is a bug in flutter when guest == null, we fix it here

D.assert(guest.width > 0.0f);
Rect intersection = guest.intersect(host);
var intersection = guest.intersect(host);
// We are computing a "V" shaped notch, as in this diagram:
// -----\**** /-----
// \ /

// notchToCenter is the horizontal distance between the guest's center and
// the host's top edge where the notch starts (marked with "*").
// We compute notchToCenter by similar triangles:
float notchToCenter =
var notchToCenter =
intersection.height * (guest.height / 2.0f)
/ (guest.width / 2.0f);

internal class _DiamondBorder : ShapeBorder
{
public _DiamondBorder()
{
}
return this.getOuterPath(rect, textDirection: textDirection);
return getOuterPath(rect, textDirection);
}

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_demo.cs


// of the Material and display ink effects above it. Using a
// standard Image will obscure the ink splash.
child: Ink.image(
image: new FileImage(this.destination.assetPackage + "/" +
this.destination.assetName),
image: new FileImage(System.IO.Path.Combine(destination.assetPackage,
destination.assetName)),
fit: BoxFit.cover,
child: new Container()
)

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs


using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/leave_behind_demo.cs


using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/overscroll_demo.cs


using System;
using System.Collections.Generic;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.widgets;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/text_form_field_demo.cs


using uiwidgets;
using UIWidgets.Runtime.material;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs


using System.Xml.Serialization;
using UIWidgetsGallery.demo.shrine.model;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/model/scoped_model.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs


using System.Collections.Generic;
using uiwidgets;
using UIWidgetsGallery.demo.shrine.model;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs


using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs


using System.Linq;
using UIWidgetsGallery.demo;
using UIWidgetsGallery.demo.material;
using Unity.UIWidgets.external;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.widgets;

foreach (var category in kAllGalleryDemoCategories)
result.Add(category,
kAllGalleryDemos.Where((GalleryDemo demo) => { return demo.category == category; }).ToList());
LinqUtils<GalleryDemo>.WhereList(kAllGalleryDemos,((GalleryDemo demo) => { return demo.category == category; })));
return result;
}

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs


using System.Linq;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

3
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs


using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Unity.UIWidgets.widgets.CustomPaint(
child: new Container(width: 300, height: 300, color: new Color(0XFFFFFFFF)),
foregroundPainter: new GridPainter(null)

4
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new DragDropApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

2
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ExpansionPanelSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;

101
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;

using UnityEngine.Networking;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class HttpRequestSample : UIWidgetsPanel
namespace UIWidgetsSample
protected override void main() {
ui_.runApp(new MaterialApp(
title: "Http Request Sample",
home: new Scaffold(
body:new AsyncRequestWidget(this.gameObject)
public class HttpRequestSample : UIWidgetsPanel
{
protected override void main()
{
ui_.runApp(new MaterialApp(
title: "Http Request Sample",
home: new Scaffold(
body: new AsyncRequestWidget(this.gameObject)
));
));
}
}
public class AsyncRequestWidget : StatefulWidget
{
public readonly GameObject gameObjOfUIWidgetsPanel;
public class AsyncRequestWidget : StatefulWidget {
public readonly GameObject gameObjOfUIWidgetsPanel;
public AsyncRequestWidget(GameObject gameObjOfUiWidgetsPanel, Key key = null) : base(key)
{
this.gameObjOfUIWidgetsPanel = gameObjOfUiWidgetsPanel;
}
public AsyncRequestWidget(GameObject gameObjOfUiWidgetsPanel, Key key = null) : base(key) {
this.gameObjOfUIWidgetsPanel = gameObjOfUiWidgetsPanel;
public override State createState()
{
return new _AsyncRequestWidgetState();
}
public override State createState() {
return new _AsyncRequestWidgetState();
[Serializable]
public class TimeData
{
public long currentFileTime;
}
class _AsyncRequestWidgetState : State<AsyncRequestWidget>
{
long _fileTime;
[Serializable]
public class TimeData {
public long currentFileTime;
}
public override Widget build(BuildContext context)
{
var isolate = Isolate.current;
class _AsyncRequestWidgetState : State<AsyncRequestWidget> {
long _fileTime;
public override Widget build(BuildContext context) {
var isolate = Isolate.current;
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>() {
new FlatButton(child: new Text("Click To Get Time"), onPressed: () => {
UnityWebRequest www = UnityWebRequest.Get("http://worldclockapi.com/api/json/est/now");
var asyncOperation = www.SendWebRequest();
asyncOperation.completed += operation => {
var timeData = JsonUtility.FromJson<TimeData>(www.downloadHandler.text);
using(Isolate.getScope(isolate))
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>()
{
new FlatButton(child: new Text("Click To Get Time"), onPressed: () =>
{
UnityWebRequest www = UnityWebRequest.Get("http://worldclockapi.com/api/json/est/now");
var asyncOperation = www.SendWebRequest();
asyncOperation.completed += operation =>
this.setState(() => { this._fileTime = timeData.currentFileTime; });
}
};
}),
new Text($"current file time: {this._fileTime}")
});
var timeData = JsonUtility.FromJson<TimeData>(www.downloadHandler.text);
using (Isolate.getScope(isolate))
{
this.setState(() => { this._fileTime = timeData.currentFileTime; });
}
};
}),
new Text($"current file time: {this._fileTime}")
});
}
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs


using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Color = Unity.UIWidgets.ui.Color;
namespace UIWidgetsSample {
public class LongPressSample : UIWidgetsPanel {

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new LongPressSampleWidget(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

3
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
initialRoute: "/",
textStyle: new TextStyle(fontSize: 24),
pageRouteBuilder: (settings, builder) =>

3
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using ui_ = Unity.UIWidgets.widgets.ui_;

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Container(
width: 200,
height: 400,

3
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Container(
decoration: new BoxDecoration(
border: Border.all(color: new Color(0xFFFFFF00))

4
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ToDoAppSample.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.external;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

{
ui_.runApp(
new WidgetsApp(
color: Color.white,
home: new ToDoListApp(),
pageRouteBuilder: this.pageRouteBuilder)
);

Widget contents()
{
var children = this.items.Select((item) =>
var children = LinqUtils<Widget,ToDoItem>.SelectList(this.items, (ToDoItem item) =>
{
return (Widget) new Text(
item.content, style: new TextStyle(

2
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/UIWidgetsSamplePanel.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {

2
Samples/UIWidgetsSamples_2019_4/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.2f1
m_EditorVersionWithRevision: 2019.4.2f1 (f997fc5c673b)
m_EditorVersionWithRevision: 2019.4.2f1 (f997fc5c673b)

3
add_sample.sh


mkdir Samples
cd Samples
cp -r ../../Samples/UIWidgetsSamples_2019_4/Assets UIWidgetsSamples
# skip copying samples
# cp -r ../../Samples/UIWidgetsSamples_2019_4/Assets UIWidgetsSamples
echo "Finished the sample preparation."

21
com.unity.uiwidgets/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [2.0.2-preview.1] - 2021-05-31
Major changes are as follows:
### Fixes
- Android return button support [\#168](https://github.com/Unity-Technologies/com.unity.uiwidgets/pull/168)
### New Features
- Add engine compilation scripts [\#170](https://github.com/Unity-Technologies/com.unity.uiwidgets/pull/170)
- On demand rendering support [\#166](https://github.com/Unity-Technologies/com.unity.uiwidgets/pull/166)
- [Breaking Changes] Use CreateExternalTexture API to share textures on Windows [\#153](https://github.com/Unity-Technologies/com.unity.uiwidgets/pull/153)
## [2.0.1-preview.1] - 2021-05-18
#### In this release we mainly focus on the optimization and stabilization of the framework.
#### We also upgrade UIWidgets to version 1.17.5, mainly derived from flutter 1.17.5.
### New Features
- Upgrade UIWidgets to 2.0 with breaking changes from 1.5.4 [\#145](https://github.com/Unity-Technologies/com.unity.uiwidgets/pull/145)
## [1.5.4-preview.1] - 2019-08-30
#### In this release we mainly focus on the optimization and stabilization of the framework.

144
com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs


using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.editor2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Font = Unity.UIWidgets.engine.Font;
UIWidgetsPanelWrapper _wrapper;
public UIWidgetsWindowType getWindowType() {
return UIWidgetsWindowType.EditorWindowPanel;
}
public bool isActive() {
return true;
}
public void startCoroutine(IEnumerator routing) {
this.StartCoroutine(routing);
}
public void onNewFrameScheduled() {
Repaint();
}
public Offset windowPosToScreenPos(Offset offset) {
return offset;
}
Configurations _configurations;
bool _ShowDebugLog;
UIWidgetsPanelWrapper _wrapper;
get { return Mathf.RoundToInt(position.size.x); }
get { return Mathf.RoundToInt(f: position.size.x); }
get { return Mathf.RoundToInt(position.size.y); }
get { return Mathf.RoundToInt(f: position.size.y); }
}
float _currentDevicePixelRatio {

void OnDestroy() {
D.assert(_wrapper != null);
_wrapper?.Destroy();
_wrapper = null;
Input_OnDisable();
void Update() {
_wrapper.onEditorUpdate();
_configurations = new Configurations();
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, new Dictionary<string, object>());
onEnable();
_wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio,
_configurations: _configurations);
_configurations.Clear();
void Update() {
_wrapper.onEditorUpdate();
void OnDestroy() {
D.assert(_wrapper != null);
_wrapper?.Destroy();
_wrapper = null;
Input_OnDisable();
void OnGUI()
{
void OnGUI() {
if (_wrapper.didDisplayMetricsChanged(_currentWidth, _currentHeight, _currentDevicePixelRatio)) {
_wrapper.OnDisplayMetricsChanged(_currentWidth, _currentHeight, _currentDevicePixelRatio);
if (_wrapper.didDisplayMetricsChanged(width: _currentWidth, height: _currentHeight,
dpr: _currentDevicePixelRatio)) {
_wrapper.OnDisplayMetricsChanged(width: _currentWidth, height: _currentHeight,
dpr: _currentDevicePixelRatio);
GUI.DrawTexture(new Rect(0.0f, 0.0f, position.width, position.height), _wrapper.renderTexture);
Input_OnGUIEvent(Event.current);
GUI.DrawTexture(new Rect(0.0f, 0.0f, width: position.width, height: position.height),
image: _wrapper.renderTexture);
Input_OnGUIEvent(evt: Event.current);
public UIWidgetsWindowType getWindowType() {
return UIWidgetsWindowType.EditorWindowPanel;
}
public bool isActive() {
return true;
}
public void startCoroutine(IEnumerator routing) {
this.StartCoroutine(coroutine: routing);
}
public void onNewFrameScheduled() {
Repaint();
}
public Offset windowPosToScreenPos(Offset offset) {
return offset;
}
public void mainEntry() {
main();
}
protected virtual void onEnable() {
}
protected void AddFont(string family, List<string> assets, List<int> weights) {
if (assets.Count != weights.Count) {
Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");
return;
}
var textFont = new TextFont {family = family};
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font {asset = assets[index: j], weight = weights[index: j]};
fonts[j] = font;
}
textFont.fonts = fonts;
_configurations.AddFont(family,textFont);
}
return new Vector2(position.x, position.y);
return new Vector2(x: position.x, y: position.y);
}
int _buttonToPointerId(int buttonId) {

else if (buttonId == 1) {
if (buttonId == 1) {
return -2;
}

void Input_OnGUIEvent(Event evt) {
if (evt.type == EventType.MouseDown) {
var pos = _getPointerPosition(evt.mousePosition);
_wrapper.OnPointerDown(pos, _buttonToPointerId(evt.button));
var pos = _getPointerPosition(position: evt.mousePosition);
_wrapper.OnPointerDown(pos: pos, _buttonToPointerId(buttonId: evt.button));
var pos = _getPointerPosition(evt.mousePosition);
_wrapper.OnPointerUp(pos, _buttonToPointerId(evt.button));
var pos = _getPointerPosition(position: evt.mousePosition);
_wrapper.OnPointerUp(pos: pos, _buttonToPointerId(buttonId: evt.button));
var pos = _getPointerPosition(evt.mousePosition);
_wrapper.OnMouseMove(pos);
var pos = _getPointerPosition(position: evt.mousePosition);
_wrapper.OnMouseMove(pos: pos);
var pos = _getPointerPosition(evt.mousePosition);
_wrapper.OnMouseMove(pos);
var pos = _getPointerPosition(position: evt.mousePosition);
_wrapper.OnMouseMove(pos: pos);
var pos = _getPointerPosition(evt.mousePosition);
_wrapper.OnMouseScroll(delta, pos);
var pos = _getPointerPosition(position: evt.mousePosition);
_wrapper.OnMouseScroll(delta: delta, pos: pos);
}
public void mainEntry() {
main();
}
protected virtual void main() {

}
}
}

28
com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;

public class UIWidgetsPanelEditor : RawImageEditor {
public override void OnInspectorGUI() {
base.OnInspectorGUI();
var pixelRatioProperty = serializedObject.FindProperty("devicePixelRatioOverride");
var antiAliasingProperty = serializedObject.FindProperty("hardwareAntiAliasing");
var ShowDebugLog = serializedObject.FindProperty("m_ShowDebugLog");
base.OnInspectorGUI();
EditorGUILayout.PropertyField(pixelRatioProperty);
EditorGUILayout.PropertyField(antiAliasingProperty);
EditorGUILayout.PropertyField(ShowDebugLog);
if (EditorGUI.EndChangeCheck()) {
UIWidgetsPanel.ShowDebugLog = ShowDebugLog.boolValue;
}
}
[MenuItem("UIWidgets/EnableDebug")]
public static void ToggleDebugMode(){
D.enableDebug = !D.enableDebug;
}
[MenuItem("UIWidgets/EnableDebug",true)]
public static bool CurrentDebugModeState() {
Menu.SetChecked("UIWidgets/EnableDebug", D.enableDebug );
return true;
}
}
}

2
com.unity.uiwidgets/LICENSE.md


UIWidgets copyright © 2020 Unity Technologies ApS
UIWidgets copyright © 2021 Unity Technologies ApS
Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).

2
com.unity.uiwidgets/Runtime/Plugins.meta


fileFormatVersion: 2
guid: 748885407ae664e1093421099f1ad4b6
guid: 13f5f7be9f33d144d89d2195786677c7
folderAsset: yes
DefaultImporter:
externalObjects: {}

6
com.unity.uiwidgets/Runtime/animation/animation_controller.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.physics;
using Unity.UIWidgets.ui;
using Ticker = Unity.UIWidgets.scheduler2.Ticker;
using TickerFuture = Unity.UIWidgets.scheduler2.TickerFuture;
using TickerProvider = Unity.UIWidgets.scheduler2.TickerProvider;
using Ticker = Unity.UIWidgets.scheduler.Ticker;
using TickerFuture = Unity.UIWidgets.scheduler.TickerFuture;
using TickerProvider = Unity.UIWidgets.scheduler.TickerProvider;
namespace Unity.UIWidgets.animation {
enum _AnimationDirection {

2
com.unity.uiwidgets/Runtime/animation/tween_sequence.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using System;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

267
com.unity.uiwidgets/Runtime/async/timer.cs


/*
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using System.Runtime.InteropServices;
using AOT;
using Unity.UIWidgets.ui;
#if UNITY_EDITOR
using UnityEditor;
#endif
public abstract void cancel();
public void Dispose() {
cancel();
}
public static float timeSinceStartup {
get {
#if UNITY_EDITOR
return (float) EditorApplication.timeSinceStartup;
#else
return Time.realtimeSinceStartup;
#endif
public static Timer create(TimeSpan duration, ZoneCallback callback) {
if (Zone.current == Zone.root) {
return Zone.current.createTimer(duration, callback);
}
public static TimeSpan timespanSinceStartup {
get { return TimeSpan.FromSeconds(timeSinceStartup); }
return Zone.current
.createTimer(duration, Zone.current.bindCallbackGuarded(callback));
static readonly object _syncObj = new object();
static LinkedList<Action> _callbacks = new LinkedList<Action>();
public static void runInMainFromFinalizer(Action callback) {
lock (_syncObj) {
_callbacks.AddLast(callback);
}
public static Timer create(TimeSpan duration, Action callback) {
return create(duration, () => {
callback.Invoke();
return null;
});
internal static void update() {
LinkedList<Action> callbacks;
lock (_syncObj) {
if (_callbacks.isEmpty()) {
return;
}
callbacks = _callbacks;
_callbacks = new LinkedList<Action>();
public static Timer periodic(TimeSpan duration, ZoneUnaryCallback callback) {
if (Zone.current == Zone.root) {
return Zone.current.createPeriodicTimer(duration, callback);
foreach (var callback in callbacks) {
try {
callback();
}
catch (Exception ex) {
D.logError("Error to execute runInMain callback: ", ex);
}
}
var boundCallback = Zone.current.bindUnaryCallbackGuarded(callback);
return Zone.current.createPeriodicTimer(duration, boundCallback);
}
public class TimerProvider {
readonly PriorityQueue<TimerImpl> _queue;
public TimerProvider() {
_queue = new PriorityQueue<TimerImpl>();
public static void run(ZoneCallback callback) {
create(TimeSpan.Zero, callback);
public Timer runInMain(Action callback) {
var timer = new TimerImpl(callback);
public abstract void cancel();
lock (_queue) {
_queue.enqueue(timer);
}
return timer;
public void Dispose() {
cancel();
public Timer run(TimeSpan duration, Action callback) {
var timer = new TimerImpl(duration, callback);
public abstract long tick { get; }
public abstract bool isActive { get; }
lock (_queue) {
_queue.enqueue(timer);
}
internal static Timer _createTimer(TimeSpan duration, ZoneCallback callback) {
return _Timer._createTimer(_ => callback(), (int) duration.TotalMilliseconds, false);
}
return timer;
internal static Timer _createPeriodicTimer(
TimeSpan duration, ZoneUnaryCallback callback) {
return _Timer._createTimer(callback, (int) duration.TotalMilliseconds, true);
}
public Timer periodic(TimeSpan duration, Action callback) {
var timer = new TimerImpl(duration, callback, periodic: true);
class _Timer : Timer {
long _tick = 0;
lock (_queue) {
_queue.enqueue(timer);
}
ZoneUnaryCallback _callback;
long _wakeupTime;
readonly int _milliSeconds;
readonly bool _repeating;
return timer;
_Timer(ZoneUnaryCallback callback, long wakeupTime, int milliSeconds, bool repeating) {
_callback = callback;
_wakeupTime = wakeupTime;
_milliSeconds = milliSeconds;
_repeating = repeating;
static readonly List<TimerImpl> _timers = new List<TimerImpl>();
static readonly List<TimerImpl> _appendList = new List<TimerImpl>();
public void update(Action flushMicroTasks = null) {
var now = Timer.timeSinceStartup;
_timers.Clear();
_appendList.Clear();
lock (_queue) {
while (_queue.count > 0 && _queue.peek().deadline <= now) {
var timer = _queue.dequeue();
_timers.Add(timer);
}
public static TimeSpan timespanSinceStartup {
get { return TimeSpan.FromMilliseconds(UIMonoState_timerMillisecondClock()); }
}
internal static _Timer _createTimer(ZoneUnaryCallback callback, int milliSeconds, bool repeating) {
if (milliSeconds < 0) {
milliSeconds = 0;
if (_timers.Count != 0) {
foreach (var timer in _timers) {
if (flushMicroTasks != null) {
flushMicroTasks();
}
long now = UIMonoState_timerMillisecondClock();
long wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds);
timer.invoke();
if (timer.periodic && !timer.done) {
_appendList.Add(timer);
}
}
}
_Timer timer = new _Timer(callback, wakeupTime, milliSeconds, repeating);
timer._enqueue();
if (_appendList.Count != 0) {
lock (_queue) {
foreach (var timer in _appendList) {
_queue.enqueue(timer);
}
}
}
return timer;
class TimerImpl : Timer, IComparable<TimerImpl> {
float _deadline;
readonly Action _callback;
bool _done;
public override void cancel() {
_callback = null;
}
public readonly bool periodic;
readonly TimeSpan _interval;
public override bool isActive => _callback != null;
public TimerImpl(TimeSpan duration, Action callback, bool periodic = false) {
_deadline = timeSinceStartup + (float) duration.TotalSeconds;
_callback = callback;
_done = false;
public override long tick => _tick;
this.periodic = periodic;
if (periodic) {
_interval = duration;
}
void _advanceWakeupTime() {
if (_milliSeconds > 0) {
_wakeupTime += _milliSeconds;
public TimerImpl(Action callback) {
_deadline = 0;
_callback = callback;
_done = false;
else {
_wakeupTime = UIMonoState_timerMillisecondClock();
}
public float deadline {
get { return _deadline; }
}
const long MILLI_TO_NANO = 1000000L;
void _enqueue() {
Isolate.ensureExists();
GCHandle callbackHandle = GCHandle.Alloc(this);
UIMonoState_postTaskForTime(_postTaskForTime, (IntPtr) callbackHandle, _wakeupTime * MILLI_TO_NANO);
}
public override void cancel() {
_done = true;
}
[MonoPInvokeCallback(typeof(UIMonoState_postTaskForTimeCallback))]
static void _postTaskForTime(IntPtr callbackHandle) {
GCHandle timerHandle = (GCHandle) callbackHandle;
var timer = (_Timer) timerHandle.Target;
timerHandle.Free();
public bool done {
get { return _done; }
}
public void invoke() {
if (_done) {
return;
}
try {
if (timer._callback != null) {
var callback = timer._callback;
if (!timer._repeating) {
timer._callback = null;
}
else if (timer._milliSeconds > 0) {
var ms = timer._milliSeconds;
long overdue = UIMonoState_timerMillisecondClock() - timer._wakeupTime;
if (overdue > ms) {
long missedTicks = overdue / ms;
timer._wakeupTime += missedTicks * ms;
timer._tick += missedTicks;
}
}
var now = timeSinceStartup;
if (!periodic) {
_done = true;
}
timer._tick += 1;
try {
_callback();
}
catch (Exception ex) {
D.logError("Error to execute timer callback: ", ex);
}
callback(timer);
if (periodic) {
_deadline = now + (float) _interval.TotalSeconds;
if (timer._repeating && (timer._callback != null)) {
timer._advanceWakeupTime();
timer._enqueue();
}
public int CompareTo(TimerImpl other) {
return deadline.CompareTo(other.deadline);
catch (Exception ex) {
Debug.LogException(ex);
[DllImport(NativeBindings.dllName)]
static extern long UIMonoState_timerMillisecondClock();
delegate void UIMonoState_postTaskForTimeCallback(IntPtr callbackHandle);
[DllImport(NativeBindings.dllName)]
static extern void UIMonoState_postTaskForTime(UIMonoState_postTaskForTimeCallback callback,
IntPtr callbackHandle, long targetTimeNanos);
}*/
}

2
com.unity.uiwidgets/Runtime/cupertino/button.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using TickerFuture = Unity.UIWidgets.scheduler2.TickerFuture;
using TickerFuture = Unity.UIWidgets.scheduler.TickerFuture;
namespace Unity.UIWidgets.cupertino {
public class CupertinoButtonUtils {

2
com.unity.uiwidgets/Runtime/cupertino/context_menu.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using System;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

2
com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

32
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs


using System.Globalization;
using System.Linq;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.external;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

}
DateTime selectedDateTime {
get {
return new DateTime(
return (new DateTime(
initialDateTime.Day + selectedDayFromInitial,
initialDateTime.Day,
);
)).AddDays(selectedDayFromInitial);
}
}
void _onSelectedItemChange(int index) {

);
}
bool _isValidHour(int meridiemIndex, int hourIndex) {
DateTime rangeStart = new DateTime(
DateTime rangeStart = (new DateTime(
initialDateTime.Day + selectedDayFromInitial,
initialDateTime.Day,
);
)).AddDays(selectedDayFromInitial);
// The end value of the range is exclusive, i.e. [rangeStart, rangeEnd).
DateTime rangeEnd = rangeStart.Add(new TimeSpan(0,1,0,0));

for (int index = 0; index < 24; index++) {
int minute = index * widget.minuteInterval;
DateTime date = new DateTime(
DateTime date = (new DateTime(
initialDateTime.Day + selectedDayFromInitial,
initialDateTime.Day,
);
)).AddDays(selectedDayFromInitial);
bool isInvalidMinute = (widget.minimumDate?.CompareTo(date) < 0 )
|| (widget.maximumDate?.CompareTo(date) > 0);

};
break;
}
CupertinoThemeData themeData = CupertinoTheme.of(context);
CupertinoThemeData themeData = CupertinoTheme.of(context);
return new MediaQuery(
// The native iOS picker's text scaling is fixed, so we will also fix it
// as well in our picker.

child: new DefaultTextStyle(
style: _textStyleFrom(context),
child: new Row(
children:
columns.Select((Widget child) => {
var result = new Expanded(child: child);
return (Widget) result;
}).ToList()
children: LinqUtils<Widget>.SelectList(columns, (Widget child) => {
var result = new Expanded(child: child);
return (Widget) result;
})
)
)
)

2
com.unity.uiwidgets/Runtime/cupertino/localization.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

683
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
文件差异内容过多而无法显示
查看文件

4
com.unity.uiwidgets/Runtime/cupertino/refresh.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

2
com.unity.uiwidgets/Runtime/cupertino/route.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

2
com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

2
com.unity.uiwidgets/Runtime/cupertino/slider.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

2
com.unity.uiwidgets/Runtime/cupertino/switch.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

101
com.unity.uiwidgets/Runtime/engine/DisplayMetrics.cs


using System;
using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;

public float padding_right;
}
public static class DisplayMetricsProvider {
public static Func<DisplayMetrics> provider = () => new PlayerDisplayMetrics();
}
public interface DisplayMetrics {
void OnEnable();
void OnGUI();
void Update();
void onViewMetricsChanged();
float devicePixelRatio { get; }
viewMetrics viewMetrics { get; }
public class DisplayMetrics {
float _devicePixelRatioByDefault;
WindowPadding viewPadding { get; }
WindowPadding viewInsets { get; }
}
public class PlayerDisplayMetrics : DisplayMetrics {
float _devicePixelRatio = 0;
viewMetrics? _viewMetrics = null;
public void OnEnable() {
}
public void OnGUI() {
}
public void Update() {
}
public void onViewMetricsChanged() {
//view metrics marks dirty
_viewMetrics = null;
}
public float devicePixelRatio {
public float DevicePixelRatioByDefault {
if (_devicePixelRatio > 0) {
return _devicePixelRatio;
if (_devicePixelRatioByDefault > 0) {
return _devicePixelRatioByDefault;
this._devicePixelRatio = AndroidDevicePixelRatio();
#endif
#if UNITY_WEBGL
this._devicePixelRatio = UIWidgetsWebGLDevicePixelRatio();
_devicePixelRatioByDefault = AndroidDevicePixelRatio();
this._devicePixelRatio = IOSDeviceScaleFactor();
_devicePixelRatioByDefault = IOSDeviceScaleFactor();
if (_devicePixelRatio <= 0) {
_devicePixelRatio = 1;
if (_devicePixelRatioByDefault <= 0) {
_devicePixelRatioByDefault = 1;
return _devicePixelRatio;
return _devicePixelRatioByDefault;
public WindowPadding viewPadding {
get {
return new WindowPadding(viewMetrics.padding_left,

viewMetrics.insets_bottom);
}
}
private viewMetrics? _viewMetrics;
public viewMetrics viewMetrics {
get {

#if UNITY_ANDROID
#if UNITY_ANDROID && !UNITY_EDITOR
using (
AndroidJavaClass viewController =
new AndroidJavaClass("com.unity.uiwidgets.plugin.UIWidgetsViewController")

float padding_left = metrics.Get<float>("padding_left");
float padding_right = metrics.Get<float>("padding_right");
this._viewMetrics = new viewMetrics {
_viewMetrics = new viewMetrics {
insets_bottom = insets_bottom,
insets_left = insets_left,
insets_right = insets_right,

padding_bottom = padding_bottom
};
}
#elif UNITY_WEBGL
this._viewMetrics = new viewMetrics {
insets_bottom = 0,
insets_left = 0,
insets_right = 0,
insets_top = 0,
padding_left = 0,
padding_top = 0,
padding_right = 0,
padding_bottom = 0
};
#elif UNITY_IOS
#elif !UNITY_EDITOR && UNITY_IOS
viewMetrics metrics = IOSGetViewportPadding();
this._viewMetrics = metrics;
#else

return _viewMetrics.Value;
}
}
public void onViewMetricsChanged() {
//view metrics marks dirty
_viewMetrics = null;
}
#if UNITY_ANDROID
static float AndroidDevicePixelRatio() {

}
#endif
#if UNITY_WEBGL
[DllImport("__Internal")]
static extern float UIWidgetsWebGLDevicePixelRatio();
#endif
[DllImport("__Internal")]
static extern float IOSDeviceScaleFactor();
        [DllImport("__Internal")]
        static extern float IOSDeviceScaleFactor();
[DllImport("__Internal")]
static extern viewMetrics IOSGetViewportPadding();
        [DllImport("__Internal")]
        static extern viewMetrics IOSGetViewportPadding();
}
}

23
com.unity.uiwidgets/Runtime/engine/UIWidgetsMessageManager.cs


using System.Collections.Generic;
using System.Runtime.InteropServices;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.service;
using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.engine {

readonly Dictionary<string, MethodChannelMessageDelegate> _methodChannelMessageDelegates =
new Dictionary<string, MethodChannelMessageDelegate>();
public static UIWidgetsMessageManager instance {
get { return _instance; }
get {
if (_instance == null) {
ensureUIWidgetsMessageManagerIfNeeded();
}
return _instance;
}
}
internal static void ensureUIWidgetsMessageManagerIfNeeded() {

return;
}
var managerObj = new GameObject("__UIWidgetsMessageManager");
managerObj.AddComponent<UIWidgetsMessageManager>();
var component = managerObj.AddComponent<UIWidgetsMessageManager>();
_instance = component;
}
#if UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL

void UpdateNameIfNeed() {
#if UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL
var name = this.gameObject.name;
if (name != this._lastObjectName) {
var name = gameObject.name;
if (name != _lastObjectName) {
this._lastObjectName = name;
_lastObjectName = name;
}
#endif
}

}
void OnUIWidgetsMethodMessage(string message) {
JSONObject jsonObject = (JSONObject)JSON.Parse(message);
JSONObject jsonObject = (JSONObject) JSON.Parse(message);
string channel = jsonObject["channel"].Value;
string method = jsonObject["method"].Value;
var args = new List<JSONNode>(jsonObject["args"].AsArray.Children);

653
com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs


/*using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.editor;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.rendering;
using UnityEngine.Profiling;
using UnityEngine.Scripting;
using Rect = UnityEngine.Rect;
using Texture = UnityEngine.Texture;
public class UIWidgetWindowAdapter : WindowAdapter {
readonly UIWidgetsPanel _uiWidgetsPanel;
bool _needsPaint;
public enum UIWidgetsWindowType {
InvalidPanel = 0,
GameObjectPanel = 1,
EditorWindowPanel = 2
}
[Serializable]
public struct Font {
public string asset;
public int weight;
}
protected override void updateSafeArea() {
_padding = _uiWidgetsPanel.viewPadding;
_viewInsets = _uiWidgetsPanel.viewInsets;
}
[Serializable]
public struct TextFont {
public string family;
[SerializeField] public Font[] fonts;
}
protected override bool hasFocus() {
return EventSystem.current != null &&
EventSystem.current.currentSelectedGameObject == _uiWidgetsPanel.gameObject;
}
public interface IUIWidgetsWindow {
Offset windowPosToScreenPos(Offset offset);
public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
_needsPaint = true;
}
void startCoroutine(IEnumerator routing);
public UIWidgetWindowAdapter(UIWidgetsPanel uiWidgetsPanel) {
_uiWidgetsPanel = uiWidgetsPanel;
}
bool isActive();
void mainEntry();
void onNewFrameScheduled();
public override void OnGUI(Event evt) {
if (displayMetricsChanged()) {
_needsPaint = true;
UIWidgetsWindowType getWindowType();
}
public class Configurations {
private Dictionary<string, TextFont> _textFonts = new Dictionary<string, TextFont>();
public void Clear() {
_textFonts.Clear();
}
public void AddFont(string family, TextFont font) {
_textFonts[key: family] = font;
}
public object fontsToObject() {
Dictionary<string, TextFont> settings = _textFonts;
if (settings == null || settings.Count == 0) {
return null;
if (evt.type == EventType.Repaint) {
if (!_needsPaint) {
return;
var result = new object[settings.Count];
var i = 0;
foreach (var setting in settings) {
var font = new Dictionary<string, object>();
font.Add("family", value: setting.Key);
var dic = new Dictionary<string, object>[setting.Value.fonts.Length];
for (var j = 0; j < setting.Value.fonts.Length; j++) {
dic[j] = new Dictionary<string, object>();
if (setting.Value.fonts[j].asset.Length > 0) {
dic[j].Add("asset", value: setting.Value.fonts[j].asset);
}
if (setting.Value.fonts[j].weight > 0) {
dic[j].Add("weight", value: setting.Value.fonts[j].weight);
}
_needsPaint = false;
font.Add("fonts", value: dic);
result[i] = font;
i++;
base.OnGUI(evt);
return result;
}
public partial class UIWidgetsPanel : RawImage, IUIWidgetsWindow {
static List<UIWidgetsPanel> panels = new List<UIWidgetsPanel>();
protected override Surface createSurface() {
return new WindowSurfaceImpl(_uiWidgetsPanel.applyRenderTexture);
}
static public Isolate anyIsolate {
get {
if (panels.Count == 0) {
return null;
}
public override GUIContent titleContent {
get { return new GUIContent(_uiWidgetsPanel.gameObject.name); }
return panels[0]._wrapper.isolate;
}
protected override float queryDevicePixelRatio() {
return _uiWidgetsPanel.devicePixelRatio;
static void registerPanel(UIWidgetsPanel panel) {
panels.Add(panel);
protected override int queryAntiAliasing() {
return _uiWidgetsPanel.antiAliasing;
static void unregisterPanel(UIWidgetsPanel panel) {
panels.Remove(panel);
protected override Vector2 queryWindowSize() {
var rect = _uiWidgetsPanel.rectTransform.rect;
// Here we use ReferenceEquals instead of "==" due to
// https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
// In short, "==" is overloaded for UnityEngine.Object and will bring performance issues
if (!ReferenceEquals(_uiWidgetsPanel.canvas, null)) {
var size = new Vector2(rect.width, rect.height) *
_uiWidgetsPanel.canvas.scaleFactor / _uiWidgetsPanel.devicePixelRatio;
size.x = Mathf.Round(size.x);
size.y = Mathf.Round(size.y);
return size;
}
float _devicePixelRatioOverride;
return new Vector2(0, 0);
}
public bool hardwareAntiAliasing;
public Offset windowPosToScreenPos(Offset windowPos) {
Camera camera = null;
var canvas = _uiWidgetsPanel.canvas;
if (canvas.renderMode != RenderMode.ScreenSpaceCamera) {
camera = canvas.GetComponent<GraphicRaycaster>().eventCamera;
}
public TextFont[] fonts;
var pos = new Vector2(windowPos.dx, windowPos.dy);
pos = pos * queryDevicePixelRatio() / _uiWidgetsPanel.canvas.scaleFactor;
var rectTransform = _uiWidgetsPanel.rectTransform;
var rect = rectTransform.rect;
pos.x += rect.min.x;
pos.y = rect.max.y - pos.y;
var worldPos = rectTransform.TransformPoint(new Vector2(pos.x, pos.y));
var screenPos = RectTransformUtility.WorldToScreenPoint(camera, worldPos);
return new Offset(screenPos.x, Screen.height - screenPos.y);
}
}
Configurations _configurations;
[RequireComponent(typeof(RectTransform))]
public class UIWidgetsPanel : RawImage, IPointerDownHandler, IPointerUpHandler, IDragHandler,
IPointerEnterHandler, IPointerExitHandler, WindowHost {
static Event _repaintEvent;
UIWidgetsPanelWrapper _wrapper;
[Tooltip("set to zero if you want to use the default device pixel ratio of the target platforms; otherwise the " +
"device pixel ratio will be forced to the given value on all devices.")]
[SerializeField] protected float devicePixelRatioOverride;
[Tooltip("set to true will enable the hardware anti-alias feature, which will improve the appearance of the UI greatly but " +
"making it much slower. Enable it only when seriously required.")]
[SerializeField] protected bool hardwareAntiAliasing = false;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;
int _currentWidth {
get { return Mathf.RoundToInt(rectTransform.rect.width * canvas.scaleFactor); }
}
readonly HashSet<int> _enteredPointers = new HashSet<int>();
int _currentHeight {
get { return Mathf.RoundToInt(rectTransform.rect.height * canvas.scaleFactor); }
}
bool _viewMetricsCallbackRegistered;
float _currentDevicePixelRatio {
get {
#if !UNITY_EDITOR
return _wrapper.displayMetrics.DevicePixelRatioByDefault;
#endif
var currentDpi = Screen.dpi;
if (currentDpi == 0) {
currentDpi = canvas.GetComponent<CanvasScaler>().fallbackScreenDPI;
}
bool _mouseEntered {
get { return !_enteredPointers.isEmpty(); }
return currentDpi / 96;
}
DisplayMetrics _displayMetrics;
const int mouseButtonNum = 3;
bool _viewMetricsCallbackRegistered;
_windowAdapter?.onViewMetricsChanged();
_displayMetrics?.onViewMetricsChanged();
using (Isolate.getScope(anyIsolate)) {
_wrapper.displayMetrics.onViewMetricsChanged();
Window.instance.updateSafeArea();
Window.instance.onMetricsChanged?.Invoke();
}
protected virtual void InitWindowAdapter() {
D.assert(_windowAdapter == null);
_windowAdapter = new UIWidgetWindowAdapter(this);
protected virtual void Update() {
if (!_viewMetricsCallbackRegistered) {
_viewMetricsCallbackRegistered = true;
UIWidgetsMessageManager.instance?.AddChannelMessageDelegate("ViewportMetricsChanged",
_handleViewMetricsChanged);
}
#if !UNITY_EDITOR
CollectGarbageOnDemand();
#endif
_windowAdapter.OnEnable();
Input_Update();
protected override void OnEnable() {
base.OnEnable();
#region OnDemandGC
#if !UNITY_EDITOR
// 8 MB
const long kCollectAfterAllocating = 8 * 1024 * 1024;
long lastFrameMemory = 0;
long nextCollectAt = 0;
//Disable the default touch -> mouse event conversion on mobile devices
Input.simulateMouseWithTouches = false;
void TryEnableOnDemandGC()
{
if (UIWidgetsGlobalConfiguration.EnableIncrementalGC)
{
GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
Application.lowMemory += GC.Collect;
}
}
_displayMetrics = DisplayMetricsProvider.provider();
_displayMetrics.OnEnable();
_enteredPointers.Clear();
if (_repaintEvent == null) {
_repaintEvent = new Event {type = EventType.Repaint};
void CollectGarbageOnDemand()
{
if (!UIWidgetsGlobalConfiguration.EnableIncrementalGC)
{
return;
}
var mem = Profiler.GetMonoUsedSizeLong();
if (mem < lastFrameMemory)
{
// GC happened.
nextCollectAt = mem + kCollectAfterAllocating;
}
else if (mem >= nextCollectAt)
{
// Trigger incremental GC
GarbageCollector.CollectIncremental(1000);
lastFrameMemory = mem + kCollectAfterAllocating;
InitWindowAdapter();
lastFrameMemory = mem;
}
#endif
#endregion
Widget root;
using (_windowAdapter.getScope()) {
root = createWidget();
}
#if !UNITY_EDITOR && UNITY_ANDROID
bool AndroidInitialized = true;
_windowAdapter.attachRootWidget(root);
_lastMouseMove = Input.mousePosition;
IEnumerator DoInitAndroid() {
yield return new WaitForEndOfFrame();
AndroidPlatformUtil.Init();
yield return new WaitForEndOfFrame();
enabled = true;
public float devicePixelRatio {
get {
return devicePixelRatioOverride > 0
? devicePixelRatioOverride
: _displayMetrics.devicePixelRatio;
bool IsAndroidInitialized() {
if (AndroidInitialized) {
enabled = false;
AndroidInitialized = false;
startCoroutine(DoInitAndroid());
return false;
}
public int antiAliasing {
get { return hardwareAntiAliasing ? Window.defaultAntiAliasing : 0; }
return true;
#endif
public WindowPadding viewPadding {
get { return _displayMetrics.viewPadding; }
}
protected void OnEnable() {
#if !UNITY_EDITOR && UNITY_ANDROID
if (!IsAndroidInitialized()) {return ;}
#endif
#if !UNITY_EDITOR && UNITY_IOS
//the hook API cannot be automatically called on IOS, so we need try hook it here
Hooks.tryHook();
#endif
#if !UNITY_EDITOR
TryEnableOnDemandGC();
#endif
public WindowPadding viewInsets {
get { return _displayMetrics.viewInsets; }
base.OnEnable();
D.assert(_wrapper == null);
_configurations = new Configurations();
_wrapper = new UIWidgetsPanelWrapper();
onEnable();
if (fonts != null && fonts.Length > 0) {
foreach (var font in fonts) {
AddFont(family: font.family, font: font);
}
}
_wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio,
_configurations: _configurations);
_configurations.Clear();
texture = _wrapper.renderTexture;
Input_OnEnable();
registerPanel(this);
D.assert(_windowAdapter != null);
_windowAdapter.OnDisable();
_windowAdapter = null;
unregisterPanel(this);
D.assert(_wrapper != null);
_wrapper?.Destroy();
_wrapper = null;
texture = null;
Input_OnDisable();
protected virtual Widget createWidget() {
return null;
protected virtual void OnGUI() {
Input_OnGUI();
public void recreateWidget() {
Widget root;
using (_windowAdapter.getScope()) {
root = createWidget();
protected override void OnRectTransformDimensionsChange() {
if (_wrapper != null && _wrapper.didDisplayMetricsChanged(width: _currentWidth, height: _currentHeight,
dpr: _currentDevicePixelRatio)) {
_wrapper.OnDisplayMetricsChanged(width: _currentWidth, height: _currentHeight,
dpr: _currentDevicePixelRatio);
texture = _wrapper.renderTexture;
_windowAdapter.attachRootWidget(root);
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) {
this.texture = texture;
material = mat;
public UIWidgetsWindowType getWindowType() {
return UIWidgetsWindowType.GameObjectPanel;
protected virtual void Update() {
_displayMetrics.Update();
UIWidgetsMessageManager.ensureUIWidgetsMessageManagerIfNeeded();
public bool isActive() {
return IsActive();
}
#if UNITY_ANDROID
if (Input.GetKeyDown(KeyCode.Escape)) {
this._windowAdapter.withBinding(() => { WidgetsBinding.instance.handlePopRoute(); });
}
#endif
public void startCoroutine(IEnumerator routing) {
StartCoroutine(routine: routing);
}
if (!_viewMetricsCallbackRegistered) {
_viewMetricsCallbackRegistered = true;
UIWidgetsMessageManager.instance?.AddChannelMessageDelegate("ViewportMatricsChanged",
_handleViewMetricsChanged);
}
public void onNewFrameScheduled() {
}
if (_mouseEntered) {
if (_lastMouseMove.x != Input.mousePosition.x || _lastMouseMove.y != Input.mousePosition.y) {
handleMouseMovement();
}
public Offset windowPosToScreenPos(Offset offset) {
Camera camera = null;
if (canvas.renderMode != RenderMode.ScreenSpaceCamera) {
camera = canvas.GetComponent<GraphicRaycaster>().eventCamera;
_lastMouseMove = Input.mousePosition;
var pos = new Vector2(x: offset.dx, y: offset.dy);
pos = pos * _currentDevicePixelRatio / canvas.scaleFactor;
var rect = rectTransform.rect;
pos.x += rect.min.x;
pos.y = rect.max.y - pos.y;
var worldPos = rectTransform.TransformPoint(new Vector2(x: pos.x, y: pos.y));
var screenPos = RectTransformUtility.WorldToScreenPoint(cam: camera, worldPoint: worldPos);
return new Offset(dx: screenPos.x, Screen.height - screenPos.y);
}
if (_mouseEntered) {
handleMouseScroll();
}
public void mainEntry() {
main();
}
D.assert(_windowAdapter != null);
_windowAdapter.Update();
_windowAdapter.OnGUI(_repaintEvent);
protected virtual void onEnable() {
void OnGUI() {
_displayMetrics.OnGUI();
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp) {
_windowAdapter.OnGUI(Event.current);
}
protected void AddFont(string family, TextFont font) {
_configurations.AddFont(family,font);
void handleMouseMovement() {
var pos = getPointPosition(Input.mousePosition);
if (pos == null) {
protected void AddFont(string family, List<string> assets, List<int> weights) {
if (assets.Count != weights.Count) {
Debug.LogError($"The size of {family}‘s assets should be equal to the weights'.");
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.mouse,
device: getMouseButtonDown(),
physicalX: pos.Value.x,
physicalY: pos.Value.y
));
}
void handleMouseScroll() {
if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = canvas.scaleFactor;
var pos = getPointPosition(Input.mousePosition);
if (pos == null) {
return;
}
_windowAdapter.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.Value.x,
pos.Value.y,
InputUtils.getScrollButtonKey());
var textFont = new TextFont {family = family};
var fonts = new Font[assets.Count];
for (var j = 0; j < assets.Count; j++) {
var font = new Font {asset = assets[index: j], weight = weights[index: j]};
fonts[j] = font;
textFont.fonts = fonts;
AddFont(family: family, font: textFont);
protected virtual void main() {
}
}
int getMouseButtonDown() {
//default mouse button key = left mouse button
var defaultKey = 0;
for (int key = 0; key < mouseButtonNum; key++) {
if (Input.GetMouseButton(key)) {
defaultKey = key;
break;
}
}
enum UIWidgetsInputMode
{
Mouse,
Touch
}
return InputUtils.getMouseButtonKey(defaultKey);
}
public partial class UIWidgetsPanel : IPointerDownHandler, IPointerUpHandler,
IPointerEnterHandler, IPointerExitHandler, IDragHandler {
bool _isEntered;
Vector2 _lastMousePosition;
public void OnPointerDown(PointerEventData eventData) {
var position = getPointPosition(eventData);
if (position == null) {
return;
}
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.down,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.Value.x,
physicalY: position.Value.y
));
UIWidgetsInputMode _inputMode;
void _convertPointerData(PointerEventData evt, out Vector2? position, out int pointerId) {
position = _inputMode == UIWidgetsInputMode.Mouse
? _getPointerPosition(Input.mousePosition)
: _getPointerPosition(evt);
pointerId = _inputMode == UIWidgetsInputMode.Mouse ? evt.pointerId : (-1 - evt.pointerId);
public void OnPointerUp(PointerEventData eventData) {
var position = getPointPosition(eventData);
if (position == null) {
return;
Vector2? _getPointerPosition(Vector2 position) {
var worldCamera = canvas.worldCamera;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(
rect: rectTransform, screenPoint: position, cam: worldCamera, out var localPoint)) {
var scaleFactor = canvas.scaleFactor;
localPoint.x = (localPoint.x - rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.up,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.Value.x,
physicalY: position.Value.y
));
return null;
Camera getActiveCamera() {
Vector2? _getPointerPosition(PointerEventData eventData) {
return eventCamera;
}
Vector2? getPointPosition(PointerEventData eventData) {
Camera camera = getActiveCamera();
camera, out localPoint);
eventCamera, out localPoint);
var scaleFactor = canvas.scaleFactor;
localPoint.x = (localPoint.x - rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (rectTransform.rect.max.y - localPoint.y) * scaleFactor;

Vector2? getPointPosition(Vector2 position) {
Vector2 localPoint;
Camera eventCamera = getActiveCamera();
void Input_OnEnable() {
_inputMode = Input.mousePresent ? UIWidgetsInputMode.Mouse : UIWidgetsInputMode.Touch;
}
void Input_OnDisable() {
}
void Input_Update() {
//we only process hover events for desktop applications
if (_inputMode == UIWidgetsInputMode.Mouse) {
if (_isEntered) {
if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2)) {
if (_lastMousePosition.x != Input.mousePosition.x ||
_lastMousePosition.y != Input.mousePosition.y) {
_lastMousePosition = Input.mousePosition;
_onMouseMove();
}
}
else {
_lastMousePosition = Input.mousePosition;
}
if (Input.mouseScrollDelta.magnitude != 0) {
_onScroll();
}
}
}
#if UNITY_ANDROID && !UNITY_EDITOR
if (Input.GetKeyDown(KeyCode.Escape)) {
using (Isolate.getScope(anyIsolate)) {
WidgetsBinding.instance.handlePopRoute();
}
}
#endif
}
void Input_OnGUI() {
var e = Event.current;
if (e.isKey) {
_wrapper.OnKeyDown(e: e);
}
}
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, position,
eventCamera, out localPoint);
var scaleFactor = canvas.scaleFactor;
localPoint.x = (localPoint.x - rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
void _onMouseMove() {
if (_inputMode != UIWidgetsInputMode.Mouse) {
return;
}
var pos = _getPointerPosition(Input.mousePosition);
_wrapper.OnMouseMove(pos);
public void OnDrag(PointerEventData eventData) {
var position = getPointPosition(eventData);
if (position == null) {
void _onScroll() {
if (_inputMode != UIWidgetsInputMode.Mouse) {
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.move,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.Value.x,
physicalY: position.Value.y
));
var pos = _getPointerPosition(Input.mousePosition);
_wrapper.OnMouseScroll(Input.mouseScrollDelta, pos);
var position = getPointPosition(eventData);
if (position == null) {
if (_inputMode != UIWidgetsInputMode.Mouse) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
_enteredPointers.Add(pointerKey);
_lastMouseMove = eventData.position;
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.Value.x,
physicalY: position.Value.y
));
D.assert(eventData.pointerId < 0);
_isEntered = true;
_lastMousePosition = Input.mousePosition;
var position = getPointPosition(eventData);
if (position == null) {
if (_inputMode != UIWidgetsInputMode.Mouse) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
_enteredPointers.Remove(pointerKey);
_windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.Value.x,
physicalY: position.Value.y
));
D.assert(eventData.pointerId < 0);
_isEntered = false;
_wrapper.OnPointerLeave();
public Window window {
get { return _windowAdapter; }
public void OnPointerDown(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnPointerDown(pos, pointerId);
}
public void OnPointerUp(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnPointerUp(pos, pointerId);
}
public void OnDrag(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnDrag(pos, pointerId);
}*/
}

4
com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs.meta


fileFormatVersion: 2
guid: 5f8434687aa245d9ae7f766b6109166b
timeCreated: 1545642183
guid: 305c123a2a944eba8f2b397a962323ff
timeCreated: 1597215247

5
com.unity.uiwidgets/Runtime/external/SplayTree.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Unity.UIWidgets.external
{ class SplayTree<TKey, TValue> : IDictionary<TKey, TValue> where TKey : IComparable<TKey> {
namespace Unity.UIWidgets.external {
class SplayTree<TKey, TValue> : IDictionary<TKey, TValue> where TKey : IComparable<TKey> {
SplayTreeNode root;
int count;
int version = 0;

2
com.unity.uiwidgets/Runtime/external/simplejson/SimpleJSON.cs


{
try
{
var item = m_Dict.Where(k => k.Value == aNode).First();
var item = LinqUtils<string, JSONNode>.WhereDictionary(m_Dict,(k => k.Value == aNode)).First();
m_Dict.Remove(item.Key);
return aNode;
}

7
com.unity.uiwidgets/Runtime/foundation/assertions.cs


using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.external;
using UnityEngine;
namespace Unity.UIWidgets.foundation {

D.assert(() => {
IEnumerable<DiagnosticsNode> summaries =
diagnostics.Where((DiagnosticsNode node) => node.level == DiagnosticLevel.summary);
LinqUtils<DiagnosticsNode>.WhereList(diagnostics,((DiagnosticsNode node) => node.level == DiagnosticLevel.summary));
if (summaries.Count() > 1) {
return false;
}

diagnostics.Where((DiagnosticsNode node) => node.level == DiagnosticLevel.summary);
LinqUtils<DiagnosticsNode>.WhereList(diagnostics,((DiagnosticsNode node) => node.level == DiagnosticLevel.summary));
List<DiagnosticsNode> message = new List<DiagnosticsNode>() {
new ErrorSummary("UIWidgetsError contained multiple error summaries."),
new ErrorDescription(

public override string ToString() {
TextTreeRenderer renderer = new TextTreeRenderer(wrapWidth: 400000000);
return string.Join("\n", diagnostics.Select((DiagnosticsNode node) => renderer.render(node).TrimEnd()));
return string.Join("\n", LinqUtils<string,DiagnosticsNode>.SelectList(diagnostics,((DiagnosticsNode node) => renderer.render(node).TrimEnd())));
}
public static void reportError(UIWidgetsErrorDetails details) {

4
com.unity.uiwidgets/Runtime/foundation/basic_types.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.InternalBridge;
using Unity.UIWidgets.async;
using UnityEngine;
using Object = UnityEngine.Object;

2
com.unity.uiwidgets/Runtime/foundation/binding.cs


using System.Collections;
using System.Collections.Generic;
using developer;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.foundation {

21
com.unity.uiwidgets/Runtime/foundation/collections.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.InternalBridge;
using Unity.UIWidgets.external;
namespace Unity.UIWidgets.foundation {
public static class CollectionUtils {

if (it == null) {
return null;
}
return "{ " + string.Join(", ", it.Select(item => item.ToString())) + " }";
}
public static void reset<T>(this List<T> list, int size) {
NoAllocHelpersBridge<T>.EnsureListElemCount(list, size);
}
public static ref T refAt<T>(this List<T> list, int index) {
var array = NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
return ref array[index];
return "{ " + string.Join(", ", LinqUtils<string,T>.SelectList(it,(item => item.ToString()))) + " }";
public static T[] array<T>(this List<T> list) {
return NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
}
public static List<T> CreateRepeatedList<T>(T value, int length) {
List<T> newList = new List<T>(length);
for (int i = 0; i < length; i++) {

110
com.unity.uiwidgets/Runtime/foundation/debug.cs


using System;
using System.Diagnostics;
using System.Linq;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.engine;
using UnityEngine;
namespace Unity.UIWidgets.foundation {
public static class D {
public static void logError(string message, Exception ex = null) {
Debug.LogException(new AssertionError(message, ex));
}
[Conditional("UNITY_ASSERTIONS")]
public static void assert(Func<bool> result, Func<string> message = null) {
if (UIWidgetsPanel.ShowDebugLog && !result()) {
throw new AssertionError(message != null ? message() : "");
}
}
#if UNITY_EDITOR
using UnityEditor;
#endif
[Conditional("UNITY_ASSERTIONS")]
public static void assert(bool result, Func<string> message = null) {
if (UIWidgetsPanel.ShowDebugLog && !result) {
throw new AssertionError(message != null ? message() : "");
}
}
namespace Unity.UIWidgets.foundation {
public static class D {
public static bool debugPaintPointersEnabled = false;
public static bool debugPaintPointersEnabled;
public static bool debugPaintBaselinesEnabled = false;
public static bool debugPaintBaselinesEnabled;
public static bool debugPaintSizeEnabled = false;
public static bool debugPaintSizeEnabled;
public static bool debugRepaintRainbowEnabled = false;
public static bool debugRepaintRainbowEnabled;
public static bool debugPaintLayerBordersEnabled = false;
public static bool debugPaintLayerBordersEnabled;
public static bool debugPrintMarkNeedsLayoutStacks = false;

public static HSVColor debugCurrentRepaintColor =
HSVColor.fromAHSV(0.4f, 60.0f, 1.0f, 1.0f);
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {
Path path = new Path();
public static int? debugFloatPrecision;
public static void logError(string message, Exception ex = null) {
Debug.LogException(new AssertionError(message: message, innerException: ex));
}
[Conditional("UNITY_ASSERTIONS")]
public static void assert(Func<bool> result, Func<string> message = null) {
if ( enableDebug && !result() ) {
throw new AssertionError(message != null ? message() : "");
}
}
[Conditional("UNITY_ASSERTIONS")]
public static void assert(bool result, Func<string> message = null) {
if ( enableDebug && !result ) {
throw new AssertionError(message != null ? message() : "");
}
}
#if UNITY_EDITOR
static bool? _enableDebug = null;
public static bool enableDebug {
get {
if (_enableDebug == null) {
_enableDebug = EditorPrefs.GetInt("UIWidgetsDebug") == 1;
}
return _enableDebug.Value;
}
set {
if (_enableDebug == value) {
return;
}
_enableDebug = value;
EditorPrefs.SetInt("UIWidgetsDebug",value ? 1 : 0);
}
}
#else
public static bool enableDebug => UIWidgetsGlobalConfiguration.EnableDebugAtRuntime;
#endif
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {
var path = new Path();
path.addRect(outerRect);
path.addRect(innerRect);
path.addRect(rect: outerRect);
path.addRect(rect: innerRect);
canvas.drawPath(path, paint);
canvas.drawPath(path: path, paint: paint);
_debugDrawDoubleRect(canvas, outerRect, innerRect, new Color(0x900090FF));
_debugDrawDoubleRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect,
_debugDrawDoubleRect(canvas: canvas, outerRect: outerRect, innerRect: innerRect,
new Color(0x900090FF));
_debugDrawDoubleRect(canvas: canvas,
innerRect.inflate(delta: outlineWidth).intersect(other: outerRect), innerRect: innerRect,
Paint paint = new Paint();
var paint = new Paint();
canvas.drawRect(outerRect, paint);
canvas.drawRect(rect: outerRect, paint: paint);
}
return true;

bool? debugPaintPointersEnabled = null,
bool? debugPaintLayerBordersEnabled = null,
bool? debugRepaintRainbowEnabled = null) {
bool needRepaint = false;
var needRepaint = false;
if (debugPaintSizeEnabled != null && debugPaintSizeEnabled != D.debugPaintSizeEnabled) {
D.debugPaintSizeEnabled = debugPaintSizeEnabled.Value;
needRepaint = true;

}*/
}
}
public static int? debugFloatPrecision;
public static string debugFormatFloat(float? value) {
if (value == null) {

return value.Value.ToString($"N{debugFloatPrecision}");
}
return value.Value.ToString($"N1");
return value.Value.ToString("N1");
}
}

public AssertionError(string message) : base(message) {
public AssertionError(string message) : base(message: message) {
public AssertionError(string message, Exception innerException = null) : base(message) {
public AssertionError(string message, Exception innerException = null) : base(message: message) {
this.innerException = innerException;
}

var lines = stackTrace.Split('\n');
var strippedLines = lines.Skip(1);
return string.Join("\n", strippedLines);
return string.Join("\n", values: strippedLines);
}
}
}

19
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.external;
using Unity.UIWidgets.ui;
using UnityEngine;

builder.writeStretched(config.suffixLineOne, builder.wrapWidth.Value);
}
IEnumerable<DiagnosticsNode> propertiesIterable = node.getProperties().Where(
IEnumerable<DiagnosticsNode> propertiesIterable = LinqUtils<DiagnosticsNode>.WhereList(node.getProperties(), (
);
));
List<DiagnosticsNode> properties;
if (_maxDescendentsTruncatableNode >= 0 && node.allowTruncate) {
if (propertiesIterable.Count() < _maxDescendentsTruncatableNode) {

}
if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) {
return string.Join(", ", value.Select(v => v.ToString()).ToArray());
return string.Join(", ", LinqUtils<string, T>.SelectList(value, (v => v.ToString())));
return string.Join(style == DiagnosticsTreeStyle.singleLine ? ", " : "\n",
value.Select(v => v.ToString()).ToArray());
return string.Join(style == DiagnosticsTreeStyle.singleLine ? ", " : "\n",
LinqUtils<string, T>.SelectList(value, (v => v.ToString())));
}
public override DiagnosticLevel level {

public override Dictionary<string, object> toJsonMap(DiagnosticsSerializationDelegate Delegate) {
var json = base.toJsonMap(Delegate);
if (value != null) {
json["values"] = value.Select(v => v.ToString()).ToList();
json["values"] = LinqUtils<string, T>.SelectList(value, (v => v.ToString()));
}
return json;

result.Append(joiner);
DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder();
debugFillProperties(builder);
result.Append(string.Join(joiner,
builder.properties.Where(n => !n.isFiltered(minLevel)).Select(n => n.ToString()).ToArray())
result.Append(string.Join(joiner,LinqUtils<string,DiagnosticsNode>.SelectList(
LinqUtils<DiagnosticsNode>.WhereList(builder.properties, (n => !n.isFiltered(minLevel)))
,(n => n.ToString())))
);
shallowString = result.ToString();
return true;

2
com.unity.uiwidgets/Runtime/foundation/isolates.cs


using System.ComponentModel;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.foundation {

2
com.unity.uiwidgets/Runtime/foundation/synchronous_future.cs


using System;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
namespace Unity.UIWidgets.foundation {
public class SynchronousFuture : Future {

6
com.unity.uiwidgets/Runtime/gestures/binding.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using UnityEngine;

if (evt is PointerDownEvent) {
_hitTests[evt.pointer] = hitTestResult;
}
_hitTests[evt.pointer] = hitTestResult;
D.assert(() => {
if (D.debugPrintHitTestResults) {
Debug.LogFormat("{0}: {1}", evt, hitTestResult);

26
com.unity.uiwidgets/Runtime/gestures/events.cs


properties.add(new IntProperty("buttons", buttons, defaultValue: 0, level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<bool>("down", down, level: DiagnosticLevel.debug));
properties.add(
new FloatProperty("pressure", pressure, defaultValue: 1.0, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("pressureMin", pressureMin, defaultValue: 1.0,
new FloatProperty("pressure", pressure, defaultValue: 1.0f, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("pressureMin", pressureMin, defaultValue: 1.0f,
properties.add(new FloatProperty("pressureMax", pressureMax, defaultValue: 1.0,
properties.add(new FloatProperty("pressureMax", pressureMax, defaultValue: 1.0f,
new FloatProperty("distance", distance, defaultValue: 0.0, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("distanceMin", distanceMin, defaultValue: 0.0,
new FloatProperty("distance", distance, defaultValue: 0.0f, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("distanceMin", distanceMin, defaultValue: 0.0f,
properties.add(new FloatProperty("distanceMax", distanceMax, defaultValue: 0.0,
properties.add(new FloatProperty("distanceMax", distanceMax, defaultValue: 0.0f,
properties.add(new FloatProperty("size", size, defaultValue: 0.0, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("radiusMajor", radiusMajor, defaultValue: 0.0,
properties.add(new FloatProperty("size", size, defaultValue: 0.0f, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("radiusMajor", radiusMajor, defaultValue: 0.0f,
properties.add(new FloatProperty("radiusMinor", radiusMinor, defaultValue: 0.0,
properties.add(new FloatProperty("radiusMinor", radiusMinor, defaultValue: 0.0f,
properties.add(new FloatProperty("radiusMin", radiusMin, defaultValue: 0.0,
properties.add(new FloatProperty("radiusMin", radiusMin, defaultValue: 0.0f,
properties.add(new FloatProperty("radiusMax", radiusMax, defaultValue: 0.0,
properties.add(new FloatProperty("radiusMax", radiusMax, defaultValue: 0.0f,
properties.add(new FloatProperty("orientation", orientation, defaultValue: 0.0,
properties.add(new FloatProperty("orientation", orientation, defaultValue: 0.0f,
properties.add(new FloatProperty("tilt", tilt, defaultValue: 0.0, level: DiagnosticLevel.debug));
properties.add(new FloatProperty("tilt", tilt, defaultValue: 0.0f, level: DiagnosticLevel.debug));
properties.add(new IntProperty("platformData", platformData, defaultValue: 0,
level: DiagnosticLevel.debug));
properties.add(new FlagProperty("obscured", value: obscured, ifTrue: "obscured",

2
com.unity.uiwidgets/Runtime/gestures/force_press.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.gestures {

5
com.unity.uiwidgets/Runtime/gestures/hit_test.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.external;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

public override string ToString() {
return
$"HitTestResult({(_path.isEmpty() ? "<empty path>" : string.Join(", ", _path.Select(x => x.ToString()).ToArray()))})";
}
$"HitTestResult({(_path.isEmpty() ? "<empty path>" : string.Join(", ", LinqUtils<string,HitTestEntry>.SelectList(_path, (x => x.ToString())) ))})";
}
}
}

2
com.unity.uiwidgets/Runtime/gestures/multidrag.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

2
com.unity.uiwidgets/Runtime/gestures/multitap.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

2
com.unity.uiwidgets/Runtime/gestures/recognizer.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;

4
com.unity.uiwidgets/Runtime/material/about.cs


using System.Collections.Generic;
using developer;
using uiwidgets;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.async;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

103
com.unity.uiwidgets/Runtime/material/animated_icons/animated_icons.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

using Color = Unity.UIWidgets.ui.Color;
/**
* In the animated icon data files, we have made some changes to optimize the compilation speed for il2cpp
* Specifically, we change all instance of Offsets to 2 separate floats throughout the file
*
* In this file, we change the codes a bit to support these changes. Please think twice and test on the Gallery sample
* if you want to make further changes here
*/
public static T _interpolate<T>(List<T> values, float progress, _Interpolator<T> interpolator) {
public static float _interpolate(float[] values, float progress) {
if (values.Count == 1) {
if (values.Length == 2) {
float targetIdx = MathUtils.lerpNullableFloat(0, values.Count - 1, progress);
float targetIdx = Mathf.Lerp(0, values.Length - 1, progress);
return interpolator(values[lowIdx], values[highIdx], t);
return Mathf.Lerp(values[lowIdx], values[highIdx], t);
}
public static void _interpolateOffset(float[] values, float progress, ref float x, ref float y) {
D.assert(progress <= 1.0f);
D.assert(progress >= 0.0f);
D.assert(values.Length % 2 == 0);
if (values.Length == 2) {
x = values[0];
y = values[1];
return;
}
float targetIdx = Mathf.Lerp(0, values.Length / 2 - 1, progress);
int lowIdx = targetIdx.floor();
int highIdx = targetIdx.ceil();
float t = targetIdx - lowIdx;
x = Mathf.Lerp(values[lowIdx * 2], values[highIdx * 2], t);
y = Mathf.Lerp(values[lowIdx * 2 + 1], values[highIdx * 2 + 1], t);
}
}

class _AnimatedIconPainter : AbstractCustomPainter {
public _AnimatedIconPainter(
List<_PathFrames> paths = null,
_PathFrames[] paths = null,
Animation<float> progress = null,
Color color = null,
float? scale = null,

this.uiPathFactory = uiPathFactory;
}
public readonly List<_PathFrames> paths;
public readonly _PathFrames[] paths;
public readonly Animation<float> progress;
public readonly Color color;
public readonly float? scale;

}
}
struct _PathOffset {
public float dx;
public float dy;
public _PathOffset(float x, float y) {
dx = x;
dy = y;
}
public static _PathOffset lerp(_PathOffset a, _PathOffset b, float t) {
return new _PathOffset(Mathf.Lerp(a.dx, b.dx, t), Mathf.Lerp(a.dy, b.dy, t));
}
}
List<_PathCommand> commands,
List<float> opacities
_PathCommand[] commands,
float[] opacities
public readonly List<_PathCommand> commands;
public readonly List<float> opacities;
public readonly _PathCommand[] commands;
public readonly float[] opacities;
float opacity = AnimatedIconUtils._interpolate<float>(opacities, progress, MathUtils.lerpNullableFloat);
float opacity = AnimatedIconUtils._interpolate(opacities, progress);
Paint paint = new Paint();
paint.style = PaintingStyle.fill;
paint.color = color.withOpacity(color.opacity * opacity);

}
class _PathMoveTo : _PathCommand {
public _PathMoveTo(List<Offset> points) {
public _PathMoveTo(float[] points) {
public readonly List<Offset> points;
public readonly float[] points;
Offset offset = AnimatedIconUtils._interpolate<Offset>(points, progress, Offset.lerp);
path.moveTo(offset.dx, offset.dy);
float dx = 0f, dy = 0f;
AnimatedIconUtils._interpolateOffset(points, progress, ref dx, ref dy);
path.moveTo(dx, dy);
public _PathCubicTo(List<Offset> controlPoints1, List<Offset> controlPoints2, List<Offset> targetPoints) {
public _PathCubicTo(float[] controlPoints1, float[] controlPoints2, float[] targetPoints) {
public readonly List<Offset> controlPoints2;
public readonly List<Offset> controlPoints1;
public readonly List<Offset> targetPoints;
public readonly float[] controlPoints2;
public readonly float[] controlPoints1;
public readonly float[] targetPoints;
Offset controlPoint1 = AnimatedIconUtils._interpolate<Offset>(controlPoints1, progress, Offset.lerp);
Offset controlPoint2 = AnimatedIconUtils._interpolate<Offset>(controlPoints2, progress, Offset.lerp);
Offset targetPoint = AnimatedIconUtils._interpolate<Offset>(targetPoints, progress, Offset.lerp);
float dx1 = 0f, dy1 = 0f, dx2 = 0f, dy2 = 0f, dx = 0f, dy = 0f;
AnimatedIconUtils._interpolateOffset(controlPoints1, progress, ref dx1, ref dy1);
AnimatedIconUtils._interpolateOffset(controlPoints2, progress, ref dx2, ref dy2);
AnimatedIconUtils._interpolateOffset(targetPoints, progress, ref dx, ref dy);
controlPoint1.dx, controlPoint1.dy,
controlPoint2.dx, controlPoint2.dy,
targetPoint.dx, targetPoint.dy
dx1, dy1,
dx2, dy2,
dx, dy
public _PathLineTo(List<Offset> points) {
public _PathLineTo(float[] points) {
List<Offset> points;
float[] points;
Offset point = AnimatedIconUtils._interpolate<Offset>(points, progress, Offset.lerp);
path.lineTo(point.dx, point.dy);
float dx = 0f, dy = 0f;
AnimatedIconUtils._interpolateOffset(points, progress, ref dx, ref dy);
path.lineTo(dx, dy);
}
}

4
com.unity.uiwidgets/Runtime/material/animated_icons/animated_icons_data.cs


}
class _AnimatedIconData : AnimatedIconData {
public _AnimatedIconData(Size size, List<_PathFrames> paths, bool matchTextDirection = false) {
public _AnimatedIconData(Size size, _PathFrames[] paths, bool matchTextDirection = false) {
this.size = size;
this.paths = paths;
this.matchTextDirection = matchTextDirection;

public readonly List<_PathFrames> paths;
public readonly _PathFrames[] paths;
public override bool matchTextDirection { get; }
}

992
com.unity.uiwidgets/Runtime/material/animated_icons/data/add_event.g.cs
文件差异内容过多而无法显示
查看文件

982
com.unity.uiwidgets/Runtime/material/animated_icons/data/arrow_menu.g.cs
文件差异内容过多而无法显示
查看文件

982
com.unity.uiwidgets/Runtime/material/animated_icons/data/close_menu.g.cs
文件差异内容过多而无法显示
查看文件

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存