Unity-Technologies / com.unity.uiwidgets

UIWidgets is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
https://unity.cn/uiwidgets
626 stars 78 forks source link

Render blinking when changing the rect of Camera #298

Closed baoxiehao closed 2 years ago

baoxiehao commented 2 years ago

There are 2 cameras, each one attach a canvas on which UIWidgets draws.

floatCamera.rect = new Rect (Mathf.Lerp (0.7f, 0.1f, step), 0.1f, Mathf.Lerp(0.25f, 0.8f, step), Mathf.Lerp(0.5f, 0.8f, step));

But translate the camera doesn't blink.

floatCamera.rect = new Rect (Mathf.Lerp (0.1f, 0.7f, step), 0.1f, 0.25f, 0.5f);

截屏2021-12-30 下午2 30 01
baoxiehao commented 2 years ago

btw,any suggestion on the code intelligent tips which will not be shown when writing UIWidgets pages?

zhuxingwei commented 2 years ago

Hi Thanks a lot for the feedback!

For the blinking issue, I noticed that it only happens when you are resizing the the size of the camera's view area. Although I still cannot reproduce the issue in my repo locally, I believe it could be relevant to the fact that UIWidgets has to recreate a new texture and bind it to the RawImage in Unity as well as the flutter engine when the canvas size changes: This is a relatively heavy job and often not possible to finish in one frame, resulting in empty gap frames and blink.

To solve this issue, you may try giving UIWidgets enough time to finish the job by slowing down the lerp frequency, e.g., resizing the canvas every other several frames instead of one frame. You can also share a simplified repo to us to investigate this issue.

For the second issue, you may want to use Jetbrains Rider (https://www.jetbrains.com/rider/). The dev team is using it to develop UIWidgets and like most of the functionalities (e.g., intelligent tips) it provides.