Coder Social home page Coder Social logo

connectappcn1's Introduction

UIWidgets 2.0 (preview)

中文

🚀 Join us 🚀

The team is now providing several open positions for full-time software engineer based in Shanghai, Unity China 🇨🇳.

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!

Introduction

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.

Efficiency

Using the latest Unity rendering SDKs, a UIWidgets App can run very fast and keep >60fps in most times.

Cross-Platform

A UIWidgets App can be deployed on all kinds of platforms including PCs and mobile devices directly, like any other Unity projects.

Multimedia Support

Except for basic 2D UIs, developers are also able to include 3D Models, audios, particle-systems to their UIWidgets Apps.

Developer-Friendly

A UIWidgets App can be debug in the Unity Editor directly with many advanced tools like CPU/GPU Profiling, FPS Profiling.

Example

Projects using UIWidgets

Unity Connect App

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.

Unity Chinese Doc

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.

Requirements

Unity

⚠️ 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 Unity 2021 LTS
1.5.4 and below 2019.4.10f1 and above N\A N\A
2.0.1 2019.4.26f1c1 N\A N\A
2.0.3 2019.4.26f1c1 ~ 2019.4.29f1c1 N\A N\A
2.0.4 and above 2019.4.26f1c1 ~ 2019.4.29f1c1 2020.3.24f1c2 and above 2021.3.11f1c2 and above

UIWidgets Package (video tutorial)

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 <YourProjectPath>
 git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgets

Note that there are many relatively large native libraries (>50MB) we built for UIWidget 2.0 to boost its performance. As the result, the clone progress might be a bit slow. Please kindly wait for a while until completed.

Finally, in PackageManger of unity, select add local file. select package.json under /com.unity.uiwidgets

Runtime Environment

⚠️ 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.

Getting Start

i. Overview

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.

ii. Scene Build

A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a UI Canvas in Unity.

  1. Create a new Scene by "File -> New Scene";
  2. Create a UI Canvas in the scene by "GameObject -> UI -> Canvas";
  3. Add a Panel (i.e., Panel 1) to the UI Canvas by right click on the Canvas and select "UI -> Panel". Then remove the Image Component from the Panel.

iii. Create Widget

A UIWidgets App is written in C# Scripts. Please follow the steps to create an App and play it in Unity Editor.

  1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it.

     using System.Collections.Generic;
     using uiwidgets;
     using Unity.UIWidgets.cupertino;
     using Unity.UIWidgets.engine;
     using Unity.UIWidgets.ui;
     using Unity.UIWidgets.widgets;
     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 void OnEnable()
             {
                 // if you want to use your own font or font icons.
                     // AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
                 base.OnEnable();
             }
    
             protected override void main()
             {
                 ui_.runApp(new MyApp());
             }
    
             class MyApp : StatelessWidget
             {
                 public override Widget build(BuildContext context)
                 {
                     return new CupertinoApp(
                         home: new CounterApp()
                     );
                 }
             }
         }
    
         internal class CounterApp : StatefulWidget
         {
             public override State createState()
             {
                 return new CountDemoState();
             }
         }
    
         internal class CountDemoState : State<CounterApp>
         {
             private int count = 0;
    
             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++;
                                     });
                                 },
                                 child: new Container(
                                     color: Color.fromARGB(255,0 , 255, 0),
                                     width: 100,
                                     height: 40
                                 )
                             ),
                         }
                     )
                 );
             }
         }
     }
  2. Save this script and attach it to Panel 1 as its component.

  3. Press the "Play" Button to start the App in Unity Editor.

iv. Build App

Finally, the UIWidgets App can be built to packages for any specific platform by the following steps.

  1. Open the Build Settings Panel by "File -> Build Settings..."
  2. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble all relevant resources and generate the final App package.

How to load images?

  1. Put your images files in StreamingAssets folder. e.g. image1.png.
  2. Use Image.file("image1.png") to load the image.

UIWidgets supports Gif as well!

  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 disableStart 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.

Show External Texture

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.

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. 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.

Debug UIWidgets Application

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.

Using Window Scope

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.

Learn

Samples

You can find many UIWidgets sample projects on Github, which cover different aspects and provide you learning materials in various levels:

Wiki

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.

FAQ

  1. 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.

  2. What 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 the difference between the Unity rendering engine and flutter engine.

    In UIWidgets 2.0, we wrapped the flutter engine inside a native library which is writen in C++ and used it to render on Unity Textures. Its rendering result is the same as in flutter and the performance is also better. However, in order to ensure that the flutter engine works properly along with Unity, we modified both the flutter and Unity Engine. As the result, currently UIWidgets 2.0 can only run on specific Unity versions, i.e., Unity China version and supports only part of the build targets of Unity.

    For better rendering result, performance and continuous upgrade and support, you are always suggested to use UIWidgets 2.0 for your project. Use UIWidgets 1.0 only if you need to support specific target platforms like webgl.

  3. I encountered with a link error with OpenGLES for iOS build using UIWidgets 2.0 with Unity 2020/2021 LTS.

    This is caused by Unity because it removed the dependency on OpenGLES library on Unity 2020.3. To fix this issue, please open the XCode project and manually add the OpenGLES library to the UnityFramework target.

  4. I encountered with a link error about bitcode for iOS when building UIWidgets 2.0 project using XCode.

    This is because the current default libUIWidgets.a library in the com.unity.uiwidgets/Runtime/Plugin/ios folder is built without bitcode support. To address this issue, you can either (1) turn off the Enable Bitcode in your XCode Build Option or (2) upzip and replace the original library with the one with bitcode support at engine/backup/plugin/ios_bitcode/libUIWidgets.a.zip.

Contact Us

QQ Group: UIWidgets (Group ID: 234207153)

How to Contribute

Check CONTRIBUTING.md

connectappcn1's People

Contributors

iizzaya avatar kgdev avatar luoxuguang avatar wglios avatar yczhangsjtu avatar zhuxingwei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectappcn1's Issues

error CS0234

Packages\com.unity.uiwidgets\Runtime\engine\input_utils.cs(3,19): error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Packages\com.unity.uiwidgets\Runtime\engine\UIWidgetsPanel.cs(11,30): error CS0234: The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
…………………………
Unity2019.2.21f1

安卓顶部StatusBar会遮挡App的UI内容

用的Unity 2019.4.17f1 (LTS)
ConnectAppCN用的2019.4.1f1的branch
能顺利打出安卓apk,在mumu模拟器和真机上运行,顶部的StatusBar会遮挡App,如附件截图所示
screenshot

请问是哪里还需要特别设置吗?

Question: any info about Debuger.dll?

Assets/ConnectApp/Packages/Debuger.dll

Looks pretty easy and elegant to use, just want to know where this dll comes from?

Debuger.EnableLog = Config.enableDebug;
Debuger.LogError(message: error);

安卓真机白屏

华为H8真机,夜神模拟器。
Unity2018.4.0f1, Unity2018.4.10f1, Unity2019.3.3f1, Unity2019.3.4f1, 用以上版本测试了。
v1.5.4-preview.6以下是正常的,preview.7~12都白屏,只渲染了 RawImage。

另外在previwe.12测试有这样的问题。
void setAlias() 函数参数在不同平台不同。
namespace name 'AnimatedPositioned' could not be found。
'SliverFillRemaining' is inaccessible due to its protection level。

为什么打包出Android会报错?

FileNotFoundException: Temp\gradleOut\build\outputs\apk\release\gradleOut-release.apk does not exist
System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <3c0b2fdf8ace4ae49f054e74ca773557>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <3c0b2fdf8ace4ae49f054e74ca773557>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <3c0b2fdf8ace4ae49f054e74ca773557>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <3c0b2fdf8ace4ae49f054e74ca773557>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:286)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Multi language support

Hey guys, can you include the option to change the language to spanish, english, etc?

iOS: The name 'HttpUtility' does not exist in the current context

When set target to iOS, get the following errors:

Assets/ConnectApp/Plugins/WechatPlugin.cs(94,35): error CS0103: The name 'HttpUtility' does not exist in the current context
Assets/ConnectApp/Plugins/QRScanPlugin.cs(92,49): error CS0103: The name 'HttpUtility' does not exist in the current context
Assets/ConnectApp/Plugins/JPushPlugin.cs(205,31): error CS0103: The name 'HttpUtility' does not exist in the current context

无法打开项目

添加项目到UnityHub后,无法打开项目
如下显示:
ConnectAppCN
Unity Version: Unavailable warning
collaborate Cloud Project

打开项目报错

unity:2018.4.6f1; Windows平台
下载完项目,导入UIWidgets,,刚开始有一些其他的错误,删除无用的包后就剩这一个错误
Assembly has reference to non-existent assembly 'Windows.UI.Input.Spatial' (Packages/com.unity.xr.legacyinputhelpers/Runtime/LegacyInputHelpers.asmdef)

OvershootCurve.transform(float)

Assets\ConnectApp\Components\LikeButton\Utils\LikeButtonModel.cs(56,31): error CS0506: 'OvershootCurve.transform(float)': cannot override inherited member 'Curve.transform(float)' because it is not marked virtual, abstract, or override

缺少依赖报错

gradle里也没有找到微信和播放器的依赖

我没有执行 git submodule update,连不上,我直接把 uiwidget 复制进package的,是因为这个么?

Uploading Dingtalk_20211129185027.jpg…

iOS 启动闪退

: symbol not found in flat namespace 'OBJC_CLASS$_MPVolumeView'

博主列表添加新的浏览模式

1. 效果预览




2. 目标页面入口

3. 贡献代码步骤

  1. fork 本项目到自己的仓库, clone 你自己fork 的仓库到本地
  2. 让项目能在 master 分支 (如果是 Unity Editor 版本高于 2019.2 的话,用 2019.4.1f1 分支) 上运行
  3. 从 master 切出一个新的分支,然后在新的分支上修改代码

4. 所需要的素材和数据

  1. 页面需要的 Icon 是 Icons.outline_carouselIcons.outline_list, 可以在 /Assets/ConnectApp/Constants/Visual.cs 中找到
  2. 页面涉及到的文件 /Assets/ConnectApp/Screens/BloggerScreen.cs
  3. 标注不完全的地方可以先自由发挥,后面会更新补全

群聊上传图片功能需要加强

1.选择并上传图片到群聊,无法选择原图上传,点击查看图片很糊!
2.而且无法在相册中多选图片上传!

系统IOS13.5.1

App版本:2.0.7

滑动页面卡顿

用的最新版,为啥每次滑动页面都一卡一卡的,手机配置挺高的,后台程序都清空了,其他浏览器打开网页都没见会这样卡

手机:redmi 10x pro Android10

Eorror

Assets\ConnectApp\Components\Swiper\TransformerPageView\TransformerPageView.cs(186,31): error CS0506: 'TransformerPageController.page': cannot override inherited member 'PageController.page' because it is not marked virtual, abstract, or override

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.