浏览代码
Merge pull request #188 from Unity-Technologies/window-layout-docking
Merge pull request #188 from Unity-Technologies/window-layout-docking
Change window position serialization to track closest corner/main
GitHub
7 年前
当前提交
4df636c0
共有 4 个文件被更改,包括 150 次插入 和 35 次删除
-
26MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs
-
43MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
105MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs.meta
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
public class WindowDockingLayout |
|||
{ |
|||
[SerializeField] |
|||
bool m_DockingLeft; |
|||
|
|||
public bool dockingLeft |
|||
{ |
|||
get { return m_DockingLeft; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
bool m_DockingTop; |
|||
|
|||
public bool dockingTop |
|||
{ |
|||
get { return m_DockingTop; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
float m_VerticalOffset; |
|||
|
|||
public float verticalOffset |
|||
{ |
|||
get { return m_VerticalOffset; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
float m_HorizontalOffset; |
|||
|
|||
public float horizontalOffset |
|||
{ |
|||
get { return m_HorizontalOffset; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
Vector2 m_Size; |
|||
|
|||
public Vector2 size |
|||
{ |
|||
get { return m_Size; } |
|||
} |
|||
|
|||
public void CalculateDockingCornerAndOffset(Rect layout, Rect parentLayout) |
|||
{ |
|||
Vector2 layoutCenter = new Vector2(layout.x + layout.width * .5f, layout.y + layout.height * .5f); |
|||
layoutCenter /= parentLayout.size; |
|||
|
|||
m_DockingLeft = layoutCenter.x < .5f; |
|||
m_DockingTop = layoutCenter.y < .5f; |
|||
|
|||
if (m_DockingLeft) |
|||
{ |
|||
m_HorizontalOffset = layout.x; |
|||
} |
|||
else |
|||
{ |
|||
m_HorizontalOffset = parentLayout.width - layout.x - layout.width; |
|||
} |
|||
|
|||
if (m_DockingTop) |
|||
{ |
|||
m_VerticalOffset = layout.y; |
|||
} |
|||
else |
|||
{ |
|||
m_VerticalOffset = parentLayout.height - layout.y - layout.height; |
|||
} |
|||
|
|||
m_Size = layout.size; |
|||
} |
|||
|
|||
public Rect GetLayout(Rect parentLayout) |
|||
{ |
|||
Rect layout = new Rect(); |
|||
|
|||
layout.size = size; |
|||
|
|||
if (dockingLeft) |
|||
{ |
|||
layout.x = horizontalOffset; |
|||
} |
|||
else |
|||
{ |
|||
layout.x = parentLayout.width - size.x - horizontalOffset; |
|||
} |
|||
|
|||
if (dockingTop) |
|||
{ |
|||
layout.y = verticalOffset; |
|||
} |
|||
else |
|||
{ |
|||
layout.y = parentLayout.height - size.y - verticalOffset; |
|||
} |
|||
|
|||
return layout; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5f70875ecccbc924b8f9f0d58bbb37e8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue