|
|
|
|
|
|
|
|
|
|
namespace Unity.UIWidgets.Editor { |
|
|
|
[InitializeOnLoad] |
|
|
|
public class EitorUtils { |
|
|
|
static EitorUtils() { |
|
|
|
public class EditorUtils { |
|
|
|
static EditorUtils() { |
|
|
|
DisplayMetricsProvider.provider = () => new EditorPlayerDisplayMetrics(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
float _lastDevicePixelRatio = 0; |
|
|
|
|
|
|
|
public void OnGUI() { |
|
|
|
} |
|
|
|
public void OnGUI() { |
|
|
|
} |
|
|
|
public void Update() { |
|
|
|
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio(); |
|
|
|
public void Update() { |
|
|
|
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio(); |
|
|
|
} |
|
|
|
|
|
|
|
public float DevicePixelRatio { |
|
|
|
|
|
|
|
|
|
|
internal static class GameViewUtil { |
|
|
|
|
|
|
|
static class GameViewUtil { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static float getGameViewDevicePixelRatio(float fallback = 1) { |
|
|
|
|
|
|
|
public static float getGameViewDevicePixelRatio(float fallback = 1) { |
|
|
|
loadTypeIfNeed(); |
|
|
|
|
|
|
|
EditorWindow gameview = getMainGameView(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return fallback; |
|
|
|
} |
|
|
|
} |
|
|
|
static EditorWindow getMainGameView() { |
|
|
|
IEnumerable enumerable = null; |
|
|
|
if (!getFieldValue(null, "s_GameViews", ref enumerable)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
IEnumerator enumerator = enumerable != null ? enumerable.GetEnumerator() : null; |
|
|
|
if (enumerator != null && enumerator.MoveNext()) { |
|
|
|
return enumerator.Current as EditorWindow; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
static EditorWindow getMainGameView() { |
|
|
|
IEnumerable enumerable = null; |
|
|
|
if (!getFieldValue(null, "s_GameViews", ref enumerable)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
IEnumerator enumerator = enumerable != null ? enumerable.GetEnumerator() : null; |
|
|
|
if (enumerator != null && enumerator.MoveNext()) { |
|
|
|
return enumerator.Current as EditorWindow; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
| BindingFlags.NonPublic |
|
|
|
| BindingFlags.Static | BindingFlags.Instance); |
|
|
|
| BindingFlags.NonPublic |
|
|
|
| BindingFlags.Static | BindingFlags.Instance); |
|
|
|
result = (T)fieldInfo.GetValue(ins); |
|
|
|
result = (T) fieldInfo.GetValue(ins); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var property = _gameViewType.GetProperty(name, BindingFlags.Public |
|
|
|
| BindingFlags.NonPublic | |
|
|
|
BindingFlags.Static | BindingFlags.Instance); |
|
|
|
var property = _gameViewType.GetProperty(name, |
|
|
|
BindingFlags.Public | BindingFlags.NonPublic | |
|
|
|
BindingFlags.Static | BindingFlags.Instance); |
|
|
|
if (property == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|