浏览代码

Change floating window serialization to track offset to closest corner rather than just position

/main
Jens Holm 7 年前
当前提交
358c118c
共有 1 个文件被更改,包括 25 次插入18 次删除
  1. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


[Serializable]
class FloatingWindowsLayout
{
public Rect previewLayout;
public Rect blackboardLayout;
public WindowDockingLayout previewLayout = new WindowDockingLayout();
public WindowDockingLayout blackboardLayout = new WindowDockingLayout();
}
public class GraphEditorView : VisualElement, IDisposable

m_GraphView.graphViewChanged = GraphViewChanged;
m_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
string serializedWindowLayout = EditorUserSettings.GetConfigValue(m_FloatingWindowsLayoutKey);
if (!String.IsNullOrEmpty(serializedWindowLayout))
{
m_FloatingWindowsLayout = JsonUtility.FromJson<FloatingWindowsLayout>(serializedWindowLayout);
m_MasterPreviewView.layout = m_FloatingWindowsLayout.previewLayout;
if (m_FloatingWindowsLayout.blackboardLayout.width > 0)
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.blackboardLayout;
}
else
{
m_FloatingWindowsLayout = new FloatingWindowsLayout();
}
RegisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
}
m_SearchWindowProvider = ScriptableObject.CreateInstance<SearchWindowProvider>();

}
}
void ApplySerializewindowLayouts(PostLayoutEvent evt)
{
UnregisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
m_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
string serializedWindowLayout = EditorUserSettings.GetConfigValue(m_FloatingWindowsLayoutKey);
if (!String.IsNullOrEmpty(serializedWindowLayout))
{
m_FloatingWindowsLayout = JsonUtility.FromJson<FloatingWindowsLayout>(serializedWindowLayout);
m_MasterPreviewView.layout = m_FloatingWindowsLayout.previewLayout.GetLayout(layout);
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.blackboardLayout.GetLayout(layout);
}
else
{
m_FloatingWindowsLayout = new FloatingWindowsLayout();
}
}
m_FloatingWindowsLayout.previewLayout = m_MasterPreviewView.layout;
m_FloatingWindowsLayout.blackboardLayout = m_BlackboardProvider.blackboard.layout;
m_FloatingWindowsLayout.previewLayout.CalculateDockingCornerAndOffset(m_MasterPreviewView.layout, layout);
m_FloatingWindowsLayout.blackboardLayout.CalculateDockingCornerAndOffset(m_BlackboardProvider.blackboard.layout, layout);
string serializedWindowLayout = JsonUtility.ToJson(m_FloatingWindowsLayout);
EditorUserSettings.SetConfigValue(m_FloatingWindowsLayoutKey, serializedWindowLayout);

正在加载...
取消
保存