UIWidgets 是一个 Unity 包,可帮助开发人员创建、调试和部署高效、跨平台的应用程序。
:warning: The main repository of UIWidgets is migrated to https://github.com/UIWidgets/com.unity.uiwidgets and developed at the new place. Although you can still report issues here, please try visit the new site to obtain the latest UIWidgets. Thanks!
The team is now providing several open positions for full-time software engineer based in Shanghai, Unity China :cn:.
If you are skilled in Unity or flutter and interested in UIWidgets, please join our QQ Group: UIWidgets (Group ID: 234207153), WeChat Group: UIWidgets 二群 or contact me directly (QQ: 541252510) for the oppotunity to Come and Build UIWidgets with us in Unity China!
UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient, cross-platform Apps using the Unity Engine.
UIWidgets is mainly derived from Flutter. However, taking advantage of the powerful Unity Engine, it offers developers many new features to improve their Apps as well as the develop workflow significantly.
UIWidgets 2.0 is developed for Unity China version deliberately and 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.
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.
Using the latest Unity rendering SDKs, a UIWidgets App can run very fast and keep >60fps in most times.
A UIWidgets App can be deployed on all kinds of platforms including PCs and mobile devices directly, like any other Unity projects.
Except for basic 2D UIs, developers are also able to include 3D Models, audios, particle-systems to their UIWidgets Apps.
A UIWidgets App can be debug in the Unity Editor directly with many advanced tools like CPU/GPU Profiling, FPS Profiling.
The Unity Connect App is created using UIWidgets 2.0 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/UIWidgets/ConnectAppCN2.
The official website of Unity Chinese Documentation (https://connect.unity.com/doc) is powered by UIWidgets 1.0 and open-sourced @https://github.com/UnityTech/DocCN.
:warning: UIWidgets 2.0 are only compatible with Unity China version
Specifically, the compatible Unity versions for each UIWidgets release are listed below. You can download the latest Unity on https://unity.cn/releases.
| 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.3 | 2019.4.26f1c1 ~ 2019.4.29f1c1 | N\A |
| 2.0.4 and above | 2019.4.26f1c1 ~ 2019.4.29f1c1 | 2020.3.24f1c2 and above |
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 root folder of your Unity project.
Generally, you can make it using a console (or terminal) application by just a few commands as below:
cd
git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgetsNote that there are many native libraries we built for UIWidget 2.0 to boost its performance, which are large files and hosted by Git Large File Storage. You need to install this service first and then use it to fetch these libraries.
Finally, in PackageManger of unity, select add local file. select package.json under /com.unity.uiwidgets
:warning: Though UIWidgets 1.0 is compatible to all platforms, currently UIWidgets 2.0 only supports MacOS(Intel64, Metal/OpenGLCore), iOS(Metal/OpenGLes), Android(OpenGLes) and Windows(Direct3D11). More devices will be supported in the future.
In this tutorial, we will create a very simple UIWidgets App as the kick-starter. The app contains only a text label and a button. The text label will count the times of clicks upon the button.
First of all, please open or create a Unity Project and open it with Unity Editor.
A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a UI Canvas in Unity.
A UIWidgets App is written in C# Scripts. Please follow the steps to create an App and play it in Unity Editor.
…Finally, the UIWidgets App can be built to packages for any specific platform by the following steps.
UIWidgets supports Gif as well!
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 disableStart in fullscreen and record outside safe area, make sure showStatusBar is true under UIWidgetsAndroidConfiguration
Please put images under StreamingAssets folder, a and loading it using Image.file.
You can use the new builtin API UIWidgetsExternalTextureHelper.createCompatibleExternalTexture to create a compatible render texture in Unity and render it on a Texture widget in UIWidgets. With the feature, you can easily embed 3d models, videos, etc.
in your App.
Note that currently this feature is only supported for OpenGLCore (Mac), OpenGLes (iOS&Android) and D3D11 (Windows) with Unity 2020.3.37f1c1 and newer. A simple example (i.e., 3DTest1.unity) can be found in our sample project.
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. You can enable incremental garbage collection to avoid it. You can enable this feature by setting UIWidgetsGlobalConfiguration.EnableIncrementalGC = true, and enabling Project Setting -> Player -> Other Settings -> Use incremental GC.
In the Editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
In the Player, the debug/development build will enable debug mode. The release build will disable debug mode automatically.
If you see the error AssertionError: Window.instance is null or null pointer error of Window.instance,
it means the code is not running in the window scope. In this case, you can enclose your code
with window scope as below:
using(Isolate.getScope(the isolate of your App)) {
// code dealing with UIWidgets,
// e.g. setState(() => {....})
}This is needed if the code is in methods
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 our HttpRequestSample for detail.
For callback/event handler methods from UIWidgets (e.g Widget.build, State.initState...), you don't need do
it yourself, since the framework ensure it's in window scope.
You can find many UIWidgets sample projects on Github, which cover different aspects and provide you learning materials in various levels:
The develop team is still working on the UIWidgets Wiki. However, since UIWidgets is mainly derived from Flutter, you can refer to Flutter Wiki to access detailed descriptions of UIWidgets APIs from those of their Flutter counterparts. Meanwhile, you can join our discussion channel to keep in touch with the community.
The editor crashes when openning a UIWidgets 2.0 project, e.g., the Sample projects.
Please make sure that you are using campatible Unity versions to the specific UIWidgets version. For example, UIWidgets 2.0.3 is only supported on Unity China version between 2019.4.26f1c1 and 2019.4.29f1c1. You can find the detailed information in this section.
After openning a UIWidgets 2.0 project I receive an error DllNotFoundException: libUIWidgets.
Please make sure that the native libraries are correctly downloaded to your project. You can find them under UIWidgetsPackageRoot/Runtime/Plugins. For example, the libUIWidgets.dll under the sub folder X86_64 is the native library for Windows and the libUIWidgets.dylib under osx is for Mac.
If the libraries are not there or their sizes are small (<1MB), please ensure that you have installed Git Large File Storage in your computer and then try the following command line inside the UIWidgets repository.
git lfs pullWhat is the difference between UIWidgets 2.0 and UIWidgets 1.0 ?
In UIWidgets 1.0 we used Unity Graphics API for the rendering and all rendering codes are writen in C#. Therefore it is able to run freely on all platforms that Unity supports but relatively slow. The rendering result is also not exactly the same as in flutter due to th
暂无开放 Issues,或尚未同步最近议题。