浏览代码

Merge branch 'kgdev' into 'master'

fix setState

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!77
/main
Shenhua Gu 6 年前
当前提交
cc5a54e2
共有 3 个文件被更改,包括 44 次插入35 次删除
  1. 62
      Editor/editor/EditorUtils.cs
  2. 6
      Runtime/engine/DisplayMetrics.cs
  3. 11
      Runtime/widgets/framework.cs

62
Editor/editor/EditorUtils.cs


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

6
Runtime/engine/DisplayMetrics.cs


}
#if UNITY_ANDROID
_devicePixelRatio = AndroidDevicePixelRatio();
this._devicePixelRatio = AndroidDevicePixelRatio();
_devicePixelRatio = UIWidgetsWebGLDevicePixelRatio();
this._devicePixelRatio = UIWidgetsWebGLDevicePixelRatio();
_devicePixelRatio = IOSDeviceScaleFactor();
this._devicePixelRatio = IOSDeviceScaleFactor();
#endif
if (this._devicePixelRatio <= 0) {

11
Runtime/widgets/framework.cs


return true;
});
if (Window.hasInstance) {
this._setState(fn);
} else {
using (WindowProvider.of(this.context).getScope()) {
this._setState(fn);
}
}
}
void _setState(VoidCallback fn = null) {
this._element.markNeedsBuild();
}

正在加载...
取消
保存