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

Commit db1a713

Browse files
authored
Merge pull request #180 from UnityTech/iphoneplus_view
fix android view bug on Android P
2 parents 678cc1f + 4331729 commit db1a713

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
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/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() {

0 commit comments

Comments
 (0)