浏览代码

merge

/siyaoH-1.17-PlatformMessage
siyao 3 年前
当前提交
88a941ce
共有 38 个文件被更改,包括 626 次插入744 次删除
  1. 239
      README-ZH.md
  2. 266
      README.md
  3. 2
      com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta
  4. 2
      com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib.meta
  5. 2
      com.unity.uiwidgets/Runtime/painting/borders.cs
  6. 395
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  7. 2
      com.unity.uiwidgets/Runtime/services/text_input.cs
  8. 8
      com.unity.uiwidgets/Runtime/ui/window.cs
  9. 4
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  10. 2
      com.unity.uiwidgets/Runtime/widgets/page_view.cs
  11. 34
      engine/Build.bee.cs
  12. 4
      engine/src/lib/ui/ui_mono_state.cc
  13. 2
      engine/src/lib/ui/ui_mono_state.h
  14. 3
      engine/src/lib/ui/window/window.cc
  15. 4
      engine/src/runtime/mono_state.cc
  16. 1
      engine/src/runtime/mono_state.h
  17. 6
      engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.h
  18. 16
      engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.mm
  19. 6
      engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.h
  20. 31
      engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.mm
  21. 12
      com.unity.uiwidgets/Runtime/Plugins/ios/custom_app_controller.h
  22. 21
      com.unity.uiwidgets/Runtime/Plugins/ios/custom_app_controller.m
  23. 14
      com.unity.uiwidgets/Runtime/Plugins/ios/device_screen.mm
  24. 37
      com.unity.uiwidgets/Runtime/Plugins/ios/device_screen.mm.meta
  25. 80
      com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a.meta
  26. 78
      com.unity.uiwidgets/Runtime/Plugins/ios/CustomAppController.m.meta
  27. 73
      com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets_d.a.meta
  28. 26
      com.unity.uiwidgets/Runtime/Plugins/ios/CustomAppController.m
  29. 0
      /com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta
  30. 0
      /com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib.meta

239
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。
安装 **Unity 2019.4.25f1c2**(_unityhub://2019.4.25f1c2/44dea2b5e6e6_)或 **Unity 2019.4.26f1c1**。 你可以从[https://unity3d.com/get-unity/download](https://unity3d.com/get-unity/download)下载最新的Unity。
访问我们的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应用通常构建在Unity UI Canvas上。 请按照以下步骤在Unity中创建一个

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"选项。
#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低,在界面变动时再将帧率提高至60。
如果您不想开启该功能,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为空函数,()=> {}即可。
#### 七、图片导入设置
请将图片放入StreamingAssets下,而后用```Image.file```读取
在Unity 2019.3版本及以上,UIWidgets将使用OnDemandRenderAPI来实现帧率调节,它将在不影响UI响应速度的情况下大幅降低耗电和发热问题。
#### 八、WebGL Canvas分辨率调整插件
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib`(目前有2018.3和2019.1)解决了这个问题。
请根据您的项目的Unity版本选择对应的插件,并禁用此插件的其他版本。方法如下:在Project面板中选中该插件,在Inspector面板中的Select platforms for plugin中,去掉WebGL后面的对勾。
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
## 调试UIWidgets应用程序
此插件覆盖了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->EnableDebug```
#### 九、图片导入设置
默认情况下,Unity会将导入图片的宽和高放缩为最近的等于2的幂的整数。
在UIWidgets中使用图片时,记得将这一特性关闭,以免图片被意外放缩,方法如下:在Project面板中选中图片,在"Inspector"面板中将"Non Power of 2"(在"Advanced"中)设置为"None"。
如果想在runtime选择是否debug,请修改文件```com.unity.uiwidgets/com.unity.uiwidgets/Runtime/foundation/debug.cs```中的```static bool debugEnableAtRuntimeInternal```
#### 十、更新表情(Emoji)
UIWidgets支持渲染文本中包含的表情。
默认的表情资源为[iOS 13.2](https://emojipedia.org/apple/ios-13.2)。
我们也准备了[Google Emoji](https://emojipedia.org/google)的表情资源。
如果您希望切换到Google版本的表情,请按如下步骤操作:
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的基本用法

266
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.
Install **Unity 2019.4.25f1c2** (_unityhub://2019.4.25f1c2/44dea2b5e6e6_) or **Unity 2019.4.26f1c1**. You can download the latest Unity on https://unity3d.com/get-unity/download.
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```.
#### Using Window Scope
## Debug UIWidgets Application
In Unity editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
If you want to change different mode in runtime, please modify the file “com.unity.uiwidgets/com.unity.uiwidgets/Runtime/foundation/debug.cs” by making “static bool debugEnableAtRuntimeInternal” to true or false. Note that the value is set to false by default.
## 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.

2
com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta


fileFormatVersion: 2
guid: 10f4716ea605f4792a332180b741682d
guid: 983c1f57f6a4847638f514f55f79c8b4
PluginImporter:
externalObjects: {}
serializedVersion: 2

2
com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib.meta


fileFormatVersion: 2
guid: 2195660b00ec74b3dbfc33fd6cbd9724
guid: 70f8ceca890db46af80df52d443eb11c
PluginImporter:
externalObjects: {}
serializedVersion: 2

2
com.unity.uiwidgets/Runtime/painting/borders.cs


get {
return borders.Aggregate(
EdgeInsets.zero,
(previousValue, border) => previousValue.add(border.dimensions));
(EdgeInsetsGeometry previousValue, ShapeBorder border) => previousValue.add(border.dimensions));
}
}

395
com.unity.uiwidgets/Runtime/painting/edge_insets.cs


return new Size(size.width - horizontal, size.height - vertical);
}
protected EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) {
public virtual EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
_left - other._left,
_right - other._right,
_start - other._start,
_end - other._end,
_top - other._top,
_bottom - other._bottom
_left.clamp(min._left, max._left),
_right.clamp(min._right, max._right),
_start.clamp(min._start, max._start),
_end.clamp(min._end, max._end),
_top.clamp(min._top, max._top),
_bottom.clamp(min._bottom, max._bottom)
public EdgeInsetsGeometry add(EdgeInsetsGeometry other) {
public virtual EdgeInsetsGeometry add(EdgeInsetsGeometry other) {
return _MixedEdgeInsets.fromLRSETB(
_left + other._left,
_right + other._right,

);
}
public virtual EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
public virtual EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) {
_left.clamp(min._left, max._left),
_right.clamp(min._right, max._right),
_start.clamp(min._start, max._start),
_end.clamp(min._end, max._end),
_top.clamp(min._top, max._top),
_bottom.clamp(min._bottom, max._bottom)
_left - other._left,
_right - other._right,
_start - other._start,
_end - other._end,
_top - other._top,
_bottom - other._bottom
public static EdgeInsetsGeometry operator -(EdgeInsetsGeometry a, EdgeInsetsGeometry b) {
public virtual EdgeInsetsGeometry multiply(float b) {
a._left - b._left,
a._right - b._right,
a._start - b._start,
a._end - b._end,
a._top - b._top,
a._bottom - b._bottom
_left * b,
_right * b,
_start * b,
_end * b,
_top * b,
_bottom * b
public static EdgeInsetsGeometry operator +(EdgeInsetsGeometry a, EdgeInsetsGeometry b) {
public virtual EdgeInsetsGeometry divide(float b) {
a._left + b._left,
a._right + b._right,
a._start + b._start,
a._end + b._end,
a._top + b._top,
a._bottom + b._bottom
_left / b,
_right / b,
_start / b,
_end / b,
_top / b,
_bottom / b
public static EdgeInsetsGeometry operator -(EdgeInsetsGeometry a) {
public virtual EdgeInsetsGeometry remainder(float b) {
-a._left,
-a._right,
-a._start,
-a._end,
-a._top,
-a._bottom
_left % b,
_right % b,
_start % b,
_end % b,
_top % b,
_bottom % b
}
public static EdgeInsetsGeometry operator -(EdgeInsetsGeometry a) {
return a.multiply(-1.0f);
}
public static EdgeInsetsGeometry operator +(EdgeInsetsGeometry a, EdgeInsetsGeometry b) {
return a.add(b);
}
public static EdgeInsetsGeometry operator -(EdgeInsetsGeometry a, EdgeInsetsGeometry b) {
return a.subtract(b);
return _MixedEdgeInsets.fromLRSETB(
a._left * other,
a._right * other,
a._start * other,
a._end * other,
a._top * other,
a._bottom * other
);
return a.multiply(other);
return _MixedEdgeInsets.fromLRSETB(
a._left / other,
a._right / other,
a._start / other,
a._end / other,
a._top / other,
a._bottom / other
);
return a.divide(other);
return _MixedEdgeInsets.fromLRSETB(
a._left % other,
a._right % other,
a._start % other,
a._end % other,
a._top % other,
a._bottom % other
);
return a.remainder(other);
public static EdgeInsetsGeometry lerp(EdgeInsetsGeometry a, EdgeInsetsGeometry b, float t) {
D.assert(t != null);

get { return fromSTEB(end, bottom, start, top); }
}
public EdgeInsetsGeometry subtract(EdgeInsetsDirectional other) {
if (other is EdgeInsetsDirectional)
return this - other;
return base.subtract(other);
public override EdgeInsetsGeometry add(EdgeInsetsGeometry other) {
return fromSTEB(
start + other._start,
end + other._end,
top + other._top,
bottom + other._bottom
);
public EdgeInsetsGeometry add(EdgeInsetsDirectional other) {
if (other is EdgeInsetsDirectional)
return this + other;
return base.add(other);
public override EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) {
return fromSTEB(
start - other._start,
end - other._end,
top - other._top,
bottom - other._bottom
);
public static EdgeInsetsDirectional operator -(EdgeInsetsDirectional a, EdgeInsetsDirectional b) {
public override EdgeInsetsGeometry multiply(float b){
a.start - b.start,
a.top - b.top,
a.end - b.end,
a.bottom - b.bottom
start * b,
end * b,
top * b,
bottom * b
public static EdgeInsetsDirectional operator +(EdgeInsetsDirectional a, EdgeInsetsDirectional b) {
public override EdgeInsetsGeometry divide(float b){
a.start + b.start,
a.top + b.top,
a.end + b.end,
a.bottom + b.bottom
start / b,
end / b,
top / b,
bottom / b
public static EdgeInsetsDirectional operator -(EdgeInsetsDirectional a) {
public override EdgeInsetsGeometry remainder(float b){
-a.start,
-a.top,
-a.end,
-a.bottom
start % b,
end % b,
top % b,
bottom % b
public static EdgeInsetsDirectional operator -(EdgeInsetsDirectional a) {
return a.multiply(-1.0f) as EdgeInsetsDirectional;
}
public static EdgeInsetsDirectional operator +(EdgeInsetsDirectional a, EdgeInsetsDirectional b) {
return a.add(b) as EdgeInsetsDirectional;
}
public static EdgeInsetsDirectional operator -(EdgeInsetsDirectional a, EdgeInsetsDirectional b) {
return a.subtract(b) as EdgeInsetsDirectional;
}
return fromSTEB(
a.start * b,
a.top * b,
a.end * b,
a.bottom * b
);
return a.multiply(b) as EdgeInsetsDirectional;
return fromSTEB(
a.start / b,
a.top / b,
a.end / b,
a.bottom / b
);
return a.divide(b) as EdgeInsetsDirectional;
return fromSTEB(
a.start % b,
a.top % b,
a.end % b,
a.bottom % b
);
return a.remainder(b) as EdgeInsetsDirectional;
public static EdgeInsetsDirectional lerp(EdgeInsetsDirectional a, EdgeInsetsDirectional b, float t) {
D.assert(t != null);

}
}
public override EdgeInsetsGeometry add(EdgeInsetsGeometry other) {
return fromLRSETB(
_left + other._left,
_right + other._right,
_start + other._start,
_end + other._end,
_top + other._top,
_bottom + other._bottom
);
}
public static _MixedEdgeInsets operator -(_MixedEdgeInsets a, _MixedEdgeInsets b) {
return _MixedEdgeInsets.fromLRSETB(
a._left - b._left,
a._right - b._right,
a._start - b._start,
a._end - b._end,
a._top - b._top,
a._bottom - b._bottom
public override EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) {
return fromLRSETB(
_left - other._left,
_right - other._right,
_start - other._start,
_end - other._end,
_top - other._top,
_bottom - other._bottom
public static _MixedEdgeInsets operator +(_MixedEdgeInsets a, _MixedEdgeInsets b) {
return _MixedEdgeInsets.fromLRSETB(
a._left + b._left,
a._right + b._right,
a._start + b._start,
a._end + b._end,
a._top + b._top,
a._bottom + b._bottom
public override EdgeInsetsGeometry multiply(float b){
return fromLRSETB(
_left * b,
_right * b,
_start * b,
_end * b,
_top * b,
_bottom * b
public static _MixedEdgeInsets operator -(_MixedEdgeInsets a) {
return _MixedEdgeInsets.fromLRSETB(
-a._left,
-a._right,
-a._start,
-a._end,
-a._top,
-a._bottom
public override EdgeInsetsGeometry divide(float b){
return fromLRSETB(
_left / b,
_right / b,
_start / b,
_end / b,
_top / b,
_bottom / b
public static _MixedEdgeInsets operator *(_MixedEdgeInsets a, float other) {
return _MixedEdgeInsets.fromLRSETB(
a._left * other,
a._right * other,
a._start * other,
a._end * other,
a._top * other,
a._bottom * other
public override EdgeInsetsGeometry remainder(float b){
return fromLRSETB(
_left % b,
_right % b,
_start % b,
_end % b,
_top % b,
_bottom % b
public static _MixedEdgeInsets operator /(_MixedEdgeInsets a, float other) {
return _MixedEdgeInsets.fromLRSETB(
a._left / other,
a._right / other,
a._start / other,
a._end / other,
a._top / other,
a._bottom / other
);
public static _MixedEdgeInsets operator -(_MixedEdgeInsets a) {
return a.multiply(-1.0f) as _MixedEdgeInsets;
}
public static _MixedEdgeInsets operator +(_MixedEdgeInsets a, _MixedEdgeInsets b) {
return a.add(b) as _MixedEdgeInsets;
}
public static _MixedEdgeInsets operator -(_MixedEdgeInsets a, _MixedEdgeInsets b) {
return a.subtract(b) as _MixedEdgeInsets;
}
public static _MixedEdgeInsets operator *(_MixedEdgeInsets a, float b) {
return a.multiply(b) as _MixedEdgeInsets;
}
public static _MixedEdgeInsets operator /(_MixedEdgeInsets a, float b) {
return a.divide(b) as _MixedEdgeInsets;
public static _MixedEdgeInsets operator %(_MixedEdgeInsets a, float other) {
return _MixedEdgeInsets.fromLRSETB(
a._left % other,
a._right % other,
a._start % other,
a._end % other,
a._top % other,
a._bottom % other
);
public static _MixedEdgeInsets operator %(_MixedEdgeInsets a, float b) {
return a.remainder(b) as _MixedEdgeInsets;
}
public override EdgeInsets resolve(TextDirection? direction) {

rect.right - right, rect.bottom - bottom);
}
public EdgeInsets subtract(EdgeInsets other) {
public override EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
left - other.left,
top - other.top,
right - other.right,
bottom - other.bottom
left.clamp(min._left, max._left),
top.clamp(min._top, max._top),
right.clamp(min._right, max._right),
bottom.clamp(min._bottom, max._bottom)
public EdgeInsets add(EdgeInsetsGeometry other) {
public override EdgeInsetsGeometry add(EdgeInsetsGeometry other) {
return fromLTRB(
left + other._left,
top + other._top,

}
public override EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
public override EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) {
left.clamp(min._left, max._left),
top.clamp(min._top, max._top),
right.clamp(min._right, max._right),
bottom.clamp(min._bottom, max._bottom)
left - other._left,
top - other._top,
right - other._right,
bottom - other._bottom
public static EdgeInsets operator -(EdgeInsets a, EdgeInsets b) {
public override EdgeInsetsGeometry multiply(float b){
a.left - b.left,
a.top - b.top,
a.right - b.right,
a.bottom - b.bottom
left * b,
top * b,
right * b,
bottom * b
public static EdgeInsets operator +(EdgeInsets a, EdgeInsets b) {
public override EdgeInsetsGeometry divide(float b){
a.left + b.left,
a.top + b.top,
a.right + b.right,
a.bottom + b.bottom
left / b,
top / b,
right / b,
bottom / b
public static EdgeInsets operator -(EdgeInsets a) {
public override EdgeInsetsGeometry remainder(float b){
-a.left,
-a.top,
-a.right,
-a.bottom
left % b,
top % b,
right % b,
bottom % b
}
public static EdgeInsets operator -(EdgeInsets a) {
return a.multiply(-1.0f) as EdgeInsets;
}
public static EdgeInsets operator +(EdgeInsets a, EdgeInsets b) {
return a.add(b) as EdgeInsets;
}
public static EdgeInsets operator -(EdgeInsets a, EdgeInsets b) {
return a.subtract(b) as EdgeInsets;
return fromLTRB(
a.left * b,
a.top * b,
a.right * b,
a.bottom * b
);
return a.multiply(b) as EdgeInsets;
return fromLTRB(
a.left / b,
a.top / b,
a.right / b,
a.bottom / b
);
return a.divide(b) as EdgeInsets;
return fromLTRB(
a.left % b,
a.top % b,
a.right % b,
a.bottom % b
);
return a.remainder(b) as EdgeInsets;
}
public static EdgeInsets lerp(EdgeInsets a, EdgeInsets b, float t) {

2
com.unity.uiwidgets/Runtime/services/text_input.cs


json["smartQuotesType"] = smartQuotesType.ToString();
json["enableSuggestions"] = enableSuggestions;
json["actionLabel"] = actionLabel;
json["inputAction"] = inputAction.ToString();
json["inputAction"] = $"TextInputAction.{inputAction.ToString()}";
json["unityTouchKeyboard"] = unityTouchKeyboard;
json["textCapitalization"] = textCapitalization.ToString();
json["keyboardAppearance"] = keyboardAppearance.ToString();

8
com.unity.uiwidgets/Runtime/ui/window.cs


public static Window instance {
get {
GCHandle gcHandle = (GCHandle) Window_instance();
IntPtr ptr = Window_instance();
if (ptr == IntPtr.Zero) {
D.assert(false, () => "AssertionError: Window.instance is null. Please enclose your code with window scope (detailed examples can be found in the README file)");
return null;
}
GCHandle gcHandle = (GCHandle) ptr;
return (Window) gcHandle.Target;
}
}

4
com.unity.uiwidgets/Runtime/widgets/navigator.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.services;
using UnityEngine;
using SchedulerBinding = Unity.UIWidgets.scheduler.SchedulerBinding;
using SchedulerPhase = Unity.UIWidgets.scheduler.SchedulerPhase;

{"name", settings.name}
};
if (settings.arguments != null) {
settingsJsonable["arguments"] = JSONMessageCodec.instance.toJson(
settings.arguments);
settingsJsonable["arguments"] = JsonUtility.ToJson(settings.arguments);
}
routeJsonable["settings"] = settingsJsonable;

2
com.unity.uiwidgets/Runtime/widgets/page_view.cs


this.dragStartBehavior = dragStartBehavior;
this.controller = controller ?? PageViewUtils._defaultPageController;
this.allowImplicitScrolling = allowImplicitScrolling;
childrenDelegate = new SliverChildListDelegate(children);
childrenDelegate = new SliverChildListDelegate(children ?? new List<Widget>());
}
public static PageView builder(

34
engine/Build.bee.cs


"src/shell/platform/unity/darwin/ios/cocoa_task_runner.h",
"src/shell/platform/unity/darwin/ios/unity_surface_manager.mm",
"src/shell/platform/unity/darwin/ios/unity_surface_manager.h",
"src/shell/platform/unity/darwin/ios/device_screen.mm",
};
np.Sources.Add(c => IsWindows(c), winSources);

"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"-Wl,--build-id=sha1",
"-g",
"-Wl,-soname=libUIWidgets_d.so",
"-Wl,-soname=libUIWidgets.so",
"-Wl,--whole-archive",
}));

dependencies.Add(builtNP.Path);
dependencies.Add(deployNP.Path);
}
Backend.Current.AddAliasDependency("ios", CopyTool.Instance().Setup("../com.unity.uiwidgets/Runtime/Plugins/iOS/CustomAppController.m", "src/external/ios/CustomAppController.m"));
np.ValidConfigurations = validConfigurations;
}

np.Libraries.Add(IsIosOrTvos, c => {
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot+"/out/ios_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
new SystemFramework("CoreFoundation"),
new SystemFramework("ImageIO"),
new SystemFramework("MobileCoreServices"),

np.Libraries.Add(IsMac, c =>
{
if(c.CodeGen == CodeGen.Debug){
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/host_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
};
} else {
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/host_release/obj/flutter/third_party/txt/libtxt_lib.a"),
};
}
});
np.Libraries.Add(IsMac, c =>
{
new StaticLibrary(flutterRoot+"/out/host_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
new SystemFramework("Foundation"),
new SystemFramework("ApplicationServices"),
new SystemFramework("OpenGL"),

np.Libraries.Add(IsAndroid, c =>
{
if(c.CodeGen == CodeGen.Debug){
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/android_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
};
} else {
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/android_release/obj/flutter/third_party/txt/libtxt_lib.a"),
};
}
});
np.Libraries.Add(IsAndroid, c =>
{
var basePath = skiaRoot + "/out/arm";
return new PrecompiledLibrary[]
{

new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtbegin_so.o"),
new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtend_so.o"),
new StaticLibrary(flutterRoot+"/out/android_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
new SystemLibrary("android_support"),
new SystemLibrary("unwind"),

4
engine/src/lib/ui/ui_mono_state.cc


return static_cast<UIMonoState*>(MonoState::Current());
}
bool UIMonoState::EnsureCurrentIsolate() {
return MonoState::EnsureCurrentIsolate();
}
void UIMonoState::SetWindow(std::unique_ptr<Window> window) {
window_ = std::move(window);
}

2
engine/src/lib/ui/ui_mono_state.h


public:
static UIMonoState* Current();
static bool EnsureCurrentIsolate();
Window* window() const { return window_.get(); }
const TaskRunners& GetTaskRunners() const;

3
engine/src/lib/ui/window/window.cc


}
UIWIDGETS_API(Mono_Handle) Window_instance() {
if (!UIMonoState::EnsureCurrentIsolate()) {
return nullptr;
}
return UIMonoState::Current()->window()->mono_window();
}

4
engine/src/runtime/mono_state.cc


return isolate_data->get();
}
bool MonoState::EnsureCurrentIsolate() {
return Mono_CurrentIsolate() != nullptr;
}
MonoState* MonoState::Current() {
auto isolate_data =
static_cast<std::shared_ptr<MonoState>*>(Mono_CurrentIsolateData());

1
engine/src/runtime/mono_state.h


static MonoState* From(Mono_Isolate isolate);
static MonoState* Current();
static bool EnsureCurrentIsolate();
std::weak_ptr<MonoState> GetWeakPtr();

6
engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.h


UnitySurfaceManager(IUnityInterfaces* unity_interfaces);
~UnitySurfaceManager();
//openGLES contexts
static EAGLContext *gl_context_;
static EAGLContext *gl_resource_context_;
void* CreateRenderTexture(size_t width, size_t height);
void ReleaseNativeRenderContext();

CVPixelBufferRef pixelbuffer_ref = nullptr;
//gl handlers
EAGLContext *gl_context_ = NULL;
EAGLContext *gl_resource_context_ = NULL;
GLuint default_fbo_ = 0;
GLuint gl_tex_ = 0;
CVOpenGLESTextureCacheRef gl_tex_cache_ref_ = nullptr;

16
engine/src/shell/platform/unity/darwin/ios/unity_surface_manager.mm


#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
namespace uiwidgets {
EAGLContext* UnitySurfaceManager::gl_context_ = nullptr;
EAGLContext* UnitySurfaceManager::gl_resource_context_ = nullptr;
UnitySurfaceManager::UnitySurfaceManager(IUnityInterfaces* unity_interfaces)
{
FML_DCHECK(metal_device_ == nullptr);

metal_device_ = metalGraphics->MetalDevice();
//create opengl context
FML_DCHECK(!gl_context_);
FML_DCHECK(!gl_resource_context_);
if (gl_context_ == nullptr && gl_resource_context_ == nullptr) {
gl_context_ = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
gl_resource_context_ = [[EAGLContext alloc] initWithAPI:[gl_context_ API] sharegroup: [gl_context_ sharegroup]];
}
gl_context_ = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
gl_resource_context_ = [[EAGLContext alloc] initWithAPI:[gl_context_ API] sharegroup: [gl_context_ sharegroup]];
FML_DCHECK(gl_context_ != nullptr && gl_resource_context_ != nullptr);
}

{
//Constants
const int ConstCVPixelFormat = kCVPixelFormatType_32BGRA;
const MTLPixelFormat ConstMetalViewPixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
const MTLPixelFormat ConstMetalViewPixelFormat = MTLPixelFormatBGRA8Unorm;
const GLuint ConstGLInternalFormat = GL_RGBA;
const GLuint ConstGLFormat = GL_BGRA_EXT;
const GLuint ConstGLType = GL_UNSIGNED_INT_8_8_8_8_REV;

void UnitySurfaceManager::ReleaseNativeRenderContext()
{
FML_DCHECK(gl_resource_context_);
gl_resource_context_ = nullptr;
gl_context_ = nullptr;
[EAGLContext setCurrentContext:nil];

6
engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.h


UnitySurfaceManager(IUnityInterfaces* unity_interfaces);
~UnitySurfaceManager();
//openGL contexts
static NSOpenGLContext *gl_context_;
static NSOpenGLContext *gl_resource_context_;
void* CreateRenderTexture(size_t width, size_t height);
void ReleaseNativeRenderContext();

//pixel buffer handles
CVPixelBufferRef pixelbuffer_ref = nullptr;
//openGL handlers
NSOpenGLContext *gl_context_ = NULL;
NSOpenGLContext *gl_resource_context_ = NULL;
GLuint default_fbo_ = 0;
GLuint gl_tex_ = 0;
CVOpenGLTextureCacheRef gl_tex_cache_ref_ = nullptr;

31
engine/src/shell/platform/unity/darwin/macos/unity_surface_manager.mm


#include "Unity/IUnityGraphicsMetal.h"
namespace uiwidgets {
NSOpenGLContext* UnitySurfaceManager::gl_context_ = nullptr;
NSOpenGLContext* UnitySurfaceManager::gl_resource_context_ = nullptr;
UnitySurfaceManager::UnitySurfaceManager(IUnityInterfaces* unity_interfaces)
{
FML_DCHECK(metal_device_ == nullptr);

metal_device_ = metalGraphics->MetalDevice();
//create opengl context
FML_DCHECK(!gl_context_);
FML_DCHECK(!gl_resource_context_);
NSOpenGLPixelFormatAttribute attrs[] =
if (gl_context_ == nullptr && gl_resource_context_ == nullptr) {
NSOpenGLPixelFormatAttribute attrs[] =
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
//gl_context_ may be created unproperly, we can check this using the relevant gl_resource_context_
//loop until the created gl_context_ is ok, otherwise the program will crash anyway
while(gl_resource_context_ == nil) {
gl_context_ = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
gl_resource_context_ = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:gl_context_];
//gl_context_ may be created unproperly, we can check this using the relevant gl_resource_context_
//loop until the created gl_context_ is ok, otherwise the program will crash anyway
while(gl_resource_context_ == nil) {
gl_context_ = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
gl_resource_context_ = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:gl_context_];
if (gl_resource_context_ == nil) {
if (gl_resource_context_ == nil) {
}
}
}

void* UnitySurfaceManager::CreateRenderTexture(size_t width, size_t height)
{
//Constants
const MTLPixelFormat ConstMetalViewPixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
const MTLPixelFormat ConstMetalViewPixelFormat = MTLPixelFormatBGRA8Unorm;
const int ConstCVPixelFormat = kCVPixelFormatType_32BGRA;
const GLuint ConstGLInternalFormat = GL_SRGB8_ALPHA8;
const GLuint ConstGLFormat = GL_BGRA;

void UnitySurfaceManager::ReleaseNativeRenderContext()
{
FML_DCHECK(gl_resource_context_);
CGLReleaseContext(gl_resource_context_.CGLContextObj);
gl_resource_context_ = nullptr;
CGLReleaseContext(gl_context_.CGLContextObj);
gl_context_ = nullptr;
FML_DCHECK(metal_device_ != nullptr);
metal_device_ = nullptr;

12
com.unity.uiwidgets/Runtime/Plugins/ios/custom_app_controller.h


#ifndef CUSTOM_APP_CONTROLLER_H
#define CUSTOM_APP_CONTROLLER_H
#import "UnityAppController.h"
@interface CustomUIWidgetsAppController : UnityAppController
{
}
- (void)shouldAttachRenderDelegate;
@end
#endif

21
com.unity.uiwidgets/Runtime/Plugins/ios/custom_app_controller.m


#if TARGET_OS_IOS
#import "UnityAppController.h"
#import <TargetConditionals.h>
#import "custom_app_controller.h"
extern void UnityPluginLoad(struct IUnityInterfaces *interfaces);
extern void UnityPluginUnload(void);
#pragma mark - App controller subclasssing
@implementation CustomUIWidgetsAppController
- (void)shouldAttachRenderDelegate;
{
UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
@end
IMPL_APP_CONTROLLER_SUBCLASS(CustomUIWidgetsAppController);
#endif

14
com.unity.uiwidgets/Runtime/Plugins/ios/device_screen.mm


#import <UIKit/UIKit.h>
#import "uiwidgets_device.h"
extern "C"
{
float IOSDeviceScaleFactor()
{
float scale = [[UIScreen mainScreen] scale] * 1.0;
if ([UIWidgetsDevice NeedScreenDownSample]) {
scale *= 0.8696;
}
return scale;
}
}

37
com.unity.uiwidgets/Runtime/Plugins/ios/device_screen.mm.meta


fileFormatVersion: 2
guid: 8020a323e242b4491be0804f10888fdc
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

80
com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a.meta


fileFormatVersion: 2
guid: fdd21868197004ea18940531d7e096ef
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

78
com.unity.uiwidgets/Runtime/Plugins/ios/CustomAppController.m.meta


fileFormatVersion: 2
guid: f00e5af3860d8467eb47452a2962aa84
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

73
com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets_d.a.meta


fileFormatVersion: 2
guid: f3c2dcb31fecb499a9df10bb178ad9b4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

26
com.unity.uiwidgets/Runtime/Plugins/ios/CustomAppController.m


#if TARGET_OS_IOS
#import "UnityAppController.h"
#import <TargetConditionals.h>
extern void UnityPluginLoad(struct IUnityInterfaces *interfaces);
extern void UnityPluginUnload(void);
#pragma mark - App controller subclasssing
@interface CustomAppController : UnityAppController
{
}
- (void)shouldAttachRenderDelegate;
@end
@implementation CustomAppController
- (void)shouldAttachRenderDelegate;
{
UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
@end
IMPL_APP_CONTROLLER_SUBCLASS(CustomAppController);
#endif

/com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets_d.so.meta → /com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta

/com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets_d.dylib.meta → /com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib.meta

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

正在加载...
取消
保存