浏览代码

IOS STATUS BAR ISSUE FIXED

/main
xingwei.zhu 6 年前
当前提交
8c75bffd
共有 4 个文件被更改,包括 75 次插入6 次删除
  1. 29
      Runtime/Plugins/platform/ios/DeviceScreen.mm
  2. 5
      Runtime/editor/editor_utils.cs
  3. 37
      Runtime/engine/DisplayMetrics.cs
  4. 10
      Runtime/engine/UIWidgetsPanel.cs

29
Runtime/Plugins/platform/ios/DeviceScreen.mm


{
return [[UIScreen mainScreen] scale];
}
struct viewPadding
{
float top;
float bottom;
float left;
float right;
};
viewPadding IOSGetViewportPadding()
{
viewPadding _viewPadding;
CGFloat scale = [[UIScreen mainScreen] scale];
if (@available(iOS 11, *)) {
_viewPadding.bottom = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom * scale;
_viewPadding.top = [UIApplication sharedApplication].keyWindow.safeAreaInsets.top * scale;
_viewPadding.left = [UIApplication sharedApplication].keyWindow.safeAreaInsets.left * scale;
_viewPadding.right = [UIApplication sharedApplication].keyWindow.safeAreaInsets.right * scale;
} else {
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame;
_viewPadding.bottom = 0;
_viewPadding.top = statusFrame.size.height * scale;
_viewPadding.left = 0;
_viewPadding.right = 0;
}
return _viewPadding;
}
}

5
Runtime/editor/editor_utils.cs


using System.Collections;
using System.Reflection;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.ui;
using UnityEngine;

public float devicePixelRatio {
get { return this._lastDevicePixelRatio; }
}
public WindowPadding viewPadding {
get { return WindowPadding.zero; }
}
}

37
Runtime/engine/DisplayMetrics.cs


using System;
using System.Runtime.InteropServices;
using UnityEngine;
using Unity.UIWidgets.ui;
[StructLayout(LayoutKind.Sequential)]
public struct ViewPadding {
public float top;
public float bottom;
public float left;
public float right;
}
public static class DisplayMetricsProvider {
public static Func<DisplayMetrics> provider = () => new PlayerDisplayMetrics();
}

void Update();
float devicePixelRatio { get; }
WindowPadding viewPadding { get; }
WindowPadding _viewPadding = null;
public void OnEnable() {
}

}
public WindowPadding viewPadding {
get {
if (this._viewPadding != null) {
return this._viewPadding;
}
#if UNITY_ANDROID
this._viewPadding = WindowPadding.zero;
#elif UNITY_WEBGL
this._viewPadding = WindowPadding.zero;
#elif UNITY_IOS
ViewPadding padding = IOSGetViewportPadding();
this._viewPadding = new WindowPadding(left: padding.left, top: padding.top, right: padding.right,
bottom: padding.bottom);
#else
this._viewPadding = WindowPadding.zero;
#endif
return this._viewPadding;
}
}
#if UNITY_ANDROID
static float AndroidDevicePixelRatio() {
using (

#if UNITY_IOS
[DllImport("__Internal")]
static extern int IOSDeviceScaleFactor();
[DllImport("__Internal")]
static extern ViewPadding IOSGetViewportPadding();
#endif
}

10
Runtime/engine/UIWidgetsPanel.cs


bool _needsPaint;
protected override void updateSafeArea() {
this._padding = new WindowPadding(
Screen.safeArea.x,
Screen.safeArea.y,
Screen.width - Screen.safeArea.width - Screen.safeArea.x,
Screen.height - Screen.safeArea.height - Screen.safeArea.y);
this._padding = this._uiWidgetsPanel.viewPadding;
}
protected override bool hasFocus() {

? this.devicePixelRatioOverride
: this._displayMetrics.devicePixelRatio;
}
}
public WindowPadding viewPadding {
get { return this._displayMetrics.viewPadding; }
}
protected override void OnDisable() {

正在加载...
取消
保存