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

Commit 7185498

Browse files
author
Yuncong Zhang
committed
Merge branch 'master' into yczhang
2 parents 1256c92 + db1a713 commit 7185498

File tree

12 files changed

+90
-82
lines changed

12 files changed

+90
-82
lines changed

README-ZH.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ 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。

README.md

Lines changed: 7 additions & 1 deletion
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

Runtime/InternalBridge.meta

Lines changed: 8 additions & 0 deletions
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/ui/painting/NoAllocHelpers.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/Unity.UIWidgets.asmdef

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "Unity.UIWidgets",
3-
"references": [],
3+
"references": [
4+
"Unity.InternalAPIEngineBridge.024"
5+
],
46
"optionalUnityReferences": [],
57
"includePlatforms": [],
68
"excludePlatforms": [],

Runtime/foundation/basic_types.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using Unity.UIWidgets.ui;
4+
using Unity.UIWidgets.InternalBridge;
55
using UnityEngine;
66
using Object = UnityEngine.Object;
77

@@ -135,16 +135,16 @@ public static string toStringList<T>(this IList<T> it) {
135135
}
136136

137137
public static void reset<T>(this List<T> list, int size) {
138-
NoAllocHelpers<T>.EnsureListElemCount(list, size);
138+
NoAllocHelpersBridge<T>.EnsureListElemCount(list, size);
139139
}
140140

141141
public static ref T refAt<T>(this List<T> list, int index) {
142-
var array = NoAllocHelpers<T>.ExtractArrayFromListT(list);
142+
var array = NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
143143
return ref array[index];
144144
}
145145

146146
public static T[] array<T>(this List<T> list) {
147-
return NoAllocHelpers<T>.ExtractArrayFromListT(list);
147+
return NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)