浏览代码

Merge branch 'master' into 'master'

device pixel ratio for edtior game view

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!65
/main
Shenhua Gu 6 年前
当前提交
ea51e7d3
共有 5 个文件被更改,包括 54 次插入14 次删除
  1. 28
      Runtime/editor/editor_window.cs
  2. 14
      Runtime/engine/DisplayMetrics.cs
  3. 3
      Runtime/engine/WidgetCanvas.cs
  4. 12
      Editor/editor/EditorUtils.cs
  5. 11
      Editor/editor/EditorUtils.cs.meta

28
Runtime/editor/editor_window.cs


}
}
protected bool displayMetricsChanged() {
if (this._devicePixelRatio != this.queryDevicePixelRatio()) {
return true;
}
var size = this.queryWindowSize();
if (this._lastWindowWidth != size.x
|| this._lastWindowHeight != size.y) {
return true;
}
return false;
}
bool dirty = false;
if (this._devicePixelRatio != this.queryDevicePixelRatio()) {
dirty = true;
}
var size = this.queryWindowSize();
if (this._lastWindowWidth != size.x
|| this._lastWindowHeight != size.y) {
dirty = true;
}
if (dirty) {
if (this.displayMetricsChanged()) {
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(

14
Runtime/engine/DisplayMetrics.cs


using System;
using System.Runtime.InteropServices;
using UnityEngine;

static float _devicePixelRatio = 0;
static Func<float> _devicePixelRatioGetter;
public static void SetDevicePixelRatioGetter(Func<float> f) {
_devicePixelRatioGetter = f;
}
if (_devicePixelRatioGetter != null) {
return _devicePixelRatioGetter();
}
if (_devicePixelRatio > 0) {
return _devicePixelRatio;
}

return _devicePixelRatio;
}
}
}
static float DevicePixelRatioAndroid() {
using (

3
Runtime/engine/WidgetCanvas.cs


public override void OnGUI(Event evt) {
if (this.displayMetricsChanged()) {
this._needsPaint = true;
}
if (evt.type == EventType.Repaint) {
if (!this._needsPaint) {
return;

12
Editor/editor/EditorUtils.cs


using Unity.UIWidgets.engine;
using UnityEditor;
namespace Unity.UIWidgets.Editor {
[InitializeOnLoad]
public class Startup {
static Startup() {
DisplayMetrics.SetDevicePixelRatioGetter(() => { return EditorGUIUtility.pixelsPerPoint; });
}
}
}

11
Editor/editor/EditorUtils.cs.meta


fileFormatVersion: 2
guid: 1b986961f22554b41b9e983888d02bfb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存