Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 44f0ee5

Browse files
committed
Merge branch 'master' of github.com:UnityTech/UIWidgets into mouse_tracking
# Conflicts: # Samples/UIWidgetsGallery/gallery/app.cs
2 parents 2b4e3f7 + 6ed6fe5 commit 44f0ee5

File tree

125 files changed

+4397
-1228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+4397
-1228
lines changed

README-ZH.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,18 @@ UIWidgets也支持Gif!
179179
当一个Unity项目运行在Android设备上时,状态栏是默认隐藏且无法在编辑内进行调整的。
180180
如果您希望在您的UIWidgets App中显示状态栏,您可以使用这个[解决方案](https://github.com/Over17/UnityShowAndroidStatusBar)。我们将尽快推出我们自己的解决方案,并保证届时开发者可以进行无缝切换。
181181

182+
此外,为了让上述插件在Android P及以上Android系统中正常工作,请勾选上"Player Settings"中的"Render Outside Safe Area"选项。
183+
182184
#### 七、自动调节帧率
183185
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
184186
默认的逻辑是在界面静止时将帧率降低为25,在界面变动时将帧率提高至60。
185187
如果您需要修改帧率升高或降低时的行为,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为您自己的函数。
186188

187189
#### 八、WebGL Canvas分辨率调整插件
188190
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
189-
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib`解决了这个问题。
190-
如果您因为任何原因需要禁止此插件,请在Project面板中选中该插件,在Inspector面板中的Define Constraints参数中,输入任意(没有被Unity定义为宏)的字符串(例如`ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`),使得只有在Player Settings中定义了这个宏,此插件才会启用。
191+
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib`(目前有2018.3和2019.1)解决了这个问题。
192+
请根据您的项目的Unity版本选择对应的插件,并禁用此插件的其他版本。方法如下:在Project面板中选中该插件,在Inspector面板中的Select platforms for plugin中,去掉WebGL后面的对勾。
193+
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
191194

192195
此插件覆盖了Unity WebGL构建模块中的如下参数:
193196
```

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ Status bar is always hidden by default when an Unity project is running on an An
208208
want to show the status bar in your App, this
209209
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
210210
compatible to UIWidgets, therefore can be used as a good option before we release our
211-
full support solution on this issue.
211+
full support solution on this issue.
212+
213+
Besides,
214+
please set "Render Outside Safe Area" to true in the "Player Settings" to make this plugin working properly on Android P or later.
215+
216+
217+
212218

213219
#### Automatically Adjust Frame Rate
214220

@@ -219,8 +225,9 @@ If you would like to modify the behavior of speeding up or cooling down the fram
219225
#### WebGL Canvas Device Pixel Ratio Plugin
220226
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
221227
Therefore, the image may blur in the builded WebGL program.
222-
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib` solves this issue.
223-
If you need to disable this plugin for any reason, please select this plugin in the **Project** panel, and put an arbitrary string (that is not defined as a macro by Unity) in the **Define Constraints** field in the **Inspector** panel (for example, `ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`), so that the plugin is enabled only if this macro is defined in **Player Settings**, which effectively disables the plugin.
228+
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib` (2018.3 and 2019.1 for now) solves this issue.
229+
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.
230+
If you need to disable this plugin for any reason, please disable all the versions of this plugin as described above.
224231

225232
This plugin overrides the following parameters in the Unity WebGL building module:
226233
```

Runtime/utils.meta renamed to Runtime/InternalBridge.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Unity.InternalAPIEngineBridge.024",
3+
"references": [],
4+
"optionalUnityReferences": [],
5+
"includePlatforms": [],
6+
"excludePlatforms": [],
7+
"allowUnsafeCode": false,
8+
"overrideReferences": false,
9+
"precompiledReferences": [],
10+
"autoReferenced": true,
11+
"defineConstraints": []
12+
}

Runtime/InternalBridge/InternalBridge.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
3+
namespace Unity.UIWidgets.InternalBridge {
4+
public static class NoAllocHelpersBridge<T> {
5+
public static T[] ExtractArrayFromListT(List<T> list) {
6+
return UnityEngine.NoAllocHelpers.ExtractArrayFromListT(list);
7+
}
8+
9+
public static void ResizeList(List<T> list, int size) {
10+
if (size < list.Count) {
11+
list.RemoveRange(size, list.Count - size);
12+
return;
13+
}
14+
15+
if (size == list.Count) {
16+
return;
17+
}
18+
19+
if (list.Capacity < size) {
20+
list.Capacity = size;
21+
}
22+
23+
UnityEngine.NoAllocHelpers.ResizeList(list, size);
24+
}
25+
26+
public static void EnsureListElemCount(List<T> list, int size) {
27+
list.Clear();
28+
if (list.Capacity < size) {
29+
list.Capacity = size;
30+
}
31+
32+
ResizeList(list, size);
33+
}
34+
}
35+
}

Runtime/utils/drag_utils.cs.meta renamed to Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Plugins/platform/android/view/UIWidgetsViewController.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static UIWidgetsViewController getInstance() {
3535
private boolean keyboardOpen;
3636

3737
private void setup() {
38-
Log.i("tag", "On Setup");
38+
//Log.i("tag", "On Setup 2");
3939

4040
keyboardOpen = false;
4141
viewMetrics = new UIWidgetsViewMetrics();
@@ -111,7 +111,7 @@ private boolean hasNavigationBar() {
111111
} catch (Exception e) {
112112
e.printStackTrace();
113113
}
114-
114+
//Log.i("UIWidgetsDebug", " hasBar: " + hasBar);
115115
return hasBar;
116116
}
117117

@@ -120,6 +120,8 @@ public void updateViewMetrics() {
120120
Rect rect = new Rect();
121121
unityView.getWindowVisibleDisplayFrame(rect);
122122

123+
//Log.i("UIWidgetsDebug", "calculation: " + unityView.getRootView().getHeight() + " " + rect.bottom + " " + rect.top);
124+
123125
rect.bottom = unityView.getRootView().getHeight() - (rect.bottom - rect.top) - rect.top;
124126
rect.right = unityView.getRootView().getWidth() - (rect.right - rect.left) - rect.left;
125127

@@ -129,9 +131,6 @@ public void updateViewMetrics() {
129131
ZeroSides zeroSides = ZeroSides.NONE;
130132
if (navigationBarHidden) {
131133
zeroSides = calculateShouldZeroSides(unityView);
132-
} else {
133-
rect.bottom -= getNavigationBarHeight();
134-
rect.bottom = rect.bottom > 0 ? rect.bottom : 0;
135134
}
136135

137136
viewMetrics.padding_top = rect.top;
@@ -143,6 +142,10 @@ public void updateViewMetrics() {
143142
viewMetrics.insets_right = 0;
144143
viewMetrics.insets_bottom = navigationBarHidden? calculateBottomKeyboardInset(rect) : rect.bottom;
145144
viewMetrics.insets_left = 0;
145+
146+
//Log.i("UIWidgetsDebug", "checks: " + navigationBarHidden + " " + rect.bottom);
147+
//Log.i("UIWidgetsDebug", " padding: " + viewMetrics.padding_top + " " + viewMetrics.padding_right + " " + viewMetrics.padding_bottom + " " + viewMetrics.padding_left);
148+
//Log.i("UIWidgetsDebug", " insets: " + viewMetrics.insets_top + " " + viewMetrics.insets_right + " " + viewMetrics.insets_bottom + " " + viewMetrics.insets_left);
146149
}
147150

148151
public void setupViewMetricsChangedListener() {

Runtime/Plugins/platform/ios/UIWidgetsViewController.mm

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ -(void)keyboardWillChangeFrame:(NSNotification*)notification {
6565
CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]);
6666
CGFloat scale = [UIScreen mainScreen].scale;
6767

68-
// scale == 3 => screen is 1242 * 2208 => we have to perform down-sampling to obtain the real length
69-
// 0.8696 = 1920 / 2208, the vertical down-sampling ratio
70-
if (scale == 3) {
71-
bottom = bottom * 0.8696;
72-
}
73-
7468
viewInsets.bottom = bottom * scale;
7569
padding.bottom = 0;
7670

@@ -100,14 +94,18 @@ viewMetrics IOSGetViewportPadding()
10094
viewMetrics metrics;
10195
viewPadding insets = [[UIWidgetsViewController sharedInstance] viewInsets];
10296
viewPadding padding = [[UIWidgetsViewController sharedInstance] padding];
103-
metrics.insets_bottom = insets.bottom;
104-
metrics.insets_top = insets.top;
105-
metrics.insets_left = insets.left;
106-
metrics.insets_right = insets.right;
107-
metrics.padding_bottom = padding.bottom;
108-
metrics.padding_top = padding.top;
109-
metrics.padding_left = padding.left;
110-
metrics.padding_right = padding.right;
97+
98+
CGFloat scale = [UIScreen mainScreen].scale;
99+
BOOL needDownsample = scale == 3;
100+
101+
metrics.insets_bottom = needDownsample ? insets.bottom * 0.8696 : insets.bottom;
102+
metrics.insets_top = needDownsample ? insets.top * 0.8696 : insets.top;
103+
metrics.insets_left = needDownsample ? insets.left * 0.8696 : insets.left;
104+
metrics.insets_right = needDownsample ? insets.right * 0.8696 : insets.right;
105+
metrics.padding_bottom = needDownsample ? padding.bottom * 0.8696 : padding.bottom;
106+
metrics.padding_top = needDownsample ? padding.top * 0.8696 : padding.top;
107+
metrics.padding_left = needDownsample ? padding.left * 0.8696 : padding.left;
108+
metrics.padding_right = needDownsample ? padding.right * 0.8696 : padding.right;
111109

112110
return metrics;
113111
}

Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib.meta

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)