|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
} |