浏览代码

ability to specify device pixel ratio manually

/main
fzhangtj 6 年前
当前提交
8eb591e6
共有 5 个文件被更改,包括 109 次插入6 次删除
  1. 11
      Runtime/engine/WidgetCanvas.cs
  2. 80
      Samples/UIWidgetSample/TextInput.unity
  3. 8
      Editor/editor.meta
  4. 16
      Editor/editor/WidgetCanvasEditor.cs

11
Runtime/engine/WidgetCanvas.cs


}
protected override double queryDevicePixelRatio() {
return this._widgetCanvas.pixelRatio;
return this._widgetCanvas.devicePixelRatio;
size = size * this._widgetCanvas.canvas.scaleFactor / (float)this._widgetCanvas.pixelRatio;
size = size * this._widgetCanvas.canvas.scaleFactor / (float)this._widgetCanvas.devicePixelRatio;
return new Vector2 (Mathf.Round (size.x), Mathf.Round (size.y));
}
}

IPointerEnterHandler, IPointerExitHandler {
static Event _repaintEvent;
[SerializeField]
protected double devicePixelRatioOverride;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;

this._lastMouseMove = Input.mousePosition;
}
public double pixelRatio {
get { return DisplayMetrics.devicePixelRatio; }
public double devicePixelRatio {
get { return this.devicePixelRatioOverride > 0 ? this.devicePixelRatioOverride : DisplayMetrics.devicePixelRatio; }
}
protected virtual Dictionary<string, WidgetBuilder> routes {

80
Samples/UIWidgetSample/TextInput.unity


m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1387978527}
- {fileID: 1354314692}
- {fileID: 1142533064}
- {fileID: 1399904531}
m_Father: {fileID: 0}

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 304189374}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1142533066
CanvasRenderer:
m_ObjectHideFlags: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1148735784}
m_CullTransparentMesh: 0
--- !u!1 &1354314691
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1354314692}
- component: {fileID: 1354314694}
- component: {fileID: 1354314693}
m_Layer: 5
m_Name: TextInput Override Ratio
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1354314692
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1354314691}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 304189374}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1354314693
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1354314691}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e9bc91696c1584e11b23dca1a9e3cde3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioOverride: 4
--- !u!222 &1354314694
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1354314691}
m_CullTransparentMesh: 0
--- !u!1 &1387978526
GameObject:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1387978529
CanvasRenderer:
m_ObjectHideFlags: 0

- {fileID: 1556903570}
- {fileID: 335487699}
m_Father: {fileID: 304189374}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}

8
Editor/editor.meta


fileFormatVersion: 2
guid: c339d59e8c37a49fdb2a6365764259fd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

16
Editor/editor/WidgetCanvasEditor.cs


using Unity.UIWidgets.engine;
using UnityEditor;
using UnityEditor.UI;
namespace Unity.UIWidgets.Editor {
[CustomEditor(typeof(WidgetCanvas), true)]
[CanEditMultipleObjects]
public class WidgetCanvasEditor : RawImageEditor {
public override void OnInspectorGUI() {
base.OnInspectorGUI();
var pixelRatioProperty = this.serializedObject.FindProperty("devicePixelRatioOverride");
EditorGUILayout.PropertyField(pixelRatioProperty);
this.serializedObject.ApplyModifiedProperties();
}
}
}
正在加载...
取消
保存