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

Commit 2e67e11

Browse files
author
Yuncong Zhang
committed
Merge branch 'master' into gallery
2 parents 4e921c2 + 40eaefb commit 2e67e11

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Runtime/Plugins/platform/ios/UIWidgetsViewController.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ -(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+
6874
viewInsets.bottom = bottom * scale;
6975
padding.bottom = 0;
7076

Runtime/engine/UIWidgetsPanel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat)
196196
protected virtual void Update() {
197197
this._displayMetrics.Update();
198198
UIWidgetsMessageManager.ensureUIWidgetsMessageManagerIfNeeded();
199+
200+
#if UNITY_ANDROID
201+
if (Input.GetKeyDown(KeyCode.Escape)) {
202+
this._windowAdapter.withBinding(() => {
203+
WidgetsBinding.instance.handlePopRoute();
204+
});
205+
}
206+
#endif
199207

200208
if (!this._viewMetricsCallbackRegistered) {
201209
this._viewMetricsCallbackRegistered = true;

Runtime/widgets/binding.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Unity.UIWidgets.foundation;
55
using Unity.UIWidgets.rendering;
66
using Unity.UIWidgets.ui;
7+
using UnityEngine;
78

89
namespace Unity.UIWidgets.widgets {
910
public interface WidgetsBindingObserver {
@@ -54,6 +55,23 @@ public bool removeObserver(WidgetsBindingObserver observer) {
5455
return this._observers.Remove(observer);
5556
}
5657

58+
public void handlePopRoute() {
59+
var idx = -1;
60+
61+
void _handlePopRouteSub(bool result) {
62+
if (!result) {
63+
idx++;
64+
if (idx >= this._observers.Count) {
65+
Application.Quit();
66+
return;
67+
}
68+
this._observers[idx].didPopRoute().Then(_handlePopRouteSub);
69+
}
70+
}
71+
72+
_handlePopRouteSub(false);
73+
}
74+
5775
public readonly WidgetInspectorService widgetInspectorService;
5876

5977
protected override void handleMetricsChanged() {

0 commit comments

Comments
 (0)