浏览代码

Reflect rename in future Unity versions of class PostLayoutEvent to GeometryChangedEvent (with fallback import for 2018.1)

/main
Peter Bay Bastian 7 年前
当前提交
5d8933e2
共有 6 个文件被更改,包括 41 次插入24 次删除
  1. 9
      com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs
  2. 9
      com.unity.shadergraph/Editor/Drawing/Manipulators/ResizeSideHandle.cs
  3. 15
      com.unity.shadergraph/Editor/Drawing/Manipulators/WindowDraggable.cs
  4. 12
      com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
  5. 15
      com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
  6. 5
      com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs

9
com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs


using UnityEditor.Graphing;
using UnityEngine.Experimental.UIElements.StyleSheets;
using Object = UnityEngine.Object;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing.Inspector
{

public void UpdateRenderTextureOnNextLayoutChange()
{
RegisterCallback<PostLayoutEvent>(AdaptRenderTextureOnLayoutChange);
RegisterCallback<GeometryChangedEvent>(AdaptRenderTextureOnLayoutChange);
void AdaptRenderTextureOnLayoutChange(PostLayoutEvent evt)
void AdaptRenderTextureOnLayoutChange(GeometryChangedEvent evt)
UnregisterCallback<PostLayoutEvent>(AdaptRenderTextureOnLayoutChange);
UnregisterCallback<GeometryChangedEvent>(AdaptRenderTextureOnLayoutChange);
RefreshRenderTextureSize();
}

9
com.unity.shadergraph/Editor/Drawing/Manipulators/ResizeSideHandle.cs


using System;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing
{

RegisterCallback<MouseDownEvent>(HandleMouseDown);
RegisterCallback<MouseUpEvent>(HandleDraggableMouseUp);
m_ResizeTarget.RegisterCallback<PostLayoutEvent>(InitialLayoutSetup);
m_ResizeTarget.RegisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
void InitialLayoutSetup(PostLayoutEvent evt)
void InitialLayoutSetup(GeometryChangedEvent evt)
m_ResizeTarget.UnregisterCallback<PostLayoutEvent>(InitialLayoutSetup);
m_ResizeTarget.UnregisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
m_InitialAspectRatio = m_ResizeTarget.layout.width / m_ResizeTarget.layout.height;
}

15
com.unity.shadergraph/Editor/Drawing/Manipulators/WindowDraggable.cs


using System;
using UnityEngine;
using UnityEngine;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing
{

m_Handle.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
target.RegisterCallback<PostLayoutEvent>(InitialLayoutSetup);
target.RegisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
}
protected override void UnregisterCallbacksFromTarget()

}
}
void InitialLayoutSetup(PostLayoutEvent postLayoutEvent)
void InitialLayoutSetup(GeometryChangedEvent GeometryChangedEvent)
target.UnregisterCallback<PostLayoutEvent>(InitialLayoutSetup);
target.RegisterCallback<PostLayoutEvent>(OnPostLayout);
target.UnregisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
target.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
void OnPostLayout(PostLayoutEvent postLayoutEvent)
void OnGeometryChanged(GeometryChangedEvent GeometryChangedEvent)
{
Rect windowRect = target.layout;

12
com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs


using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing.Util;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing
{

node.Dirty(ModificationScope.Node);
forceRedrawPreviews = false;
}
graphEditorView.HandleGraphChanges();
graphObject.graph.ClearChanges();
}

graphObject.graph.ValidateGraph();
graphEditorView = new GraphEditorView(this, m_GraphObject.graph as AbstractMaterialGraph, asset.name) { persistenceKey = selectedGuid };
graphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
titleContent = new GUIContent(asset.name);

}
}
void OnPostLayout(PostLayoutEvent evt)
void OnGeometryChanged(GeometryChangedEvent evt)
graphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
graphEditorView.graphView.FrameAll();
}
}

15
com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs


using UnityEditor.ShaderGraph.Drawing.Inspector;
using Edge = UnityEditor.Experimental.UIElements.GraphView.Edge;
using Object = UnityEngine.Object;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing
{

m_GraphView.graphViewChanged = GraphViewChanged;
RegisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
RegisterCallback<GeometryChangedEvent>(ApplySerializewindowLayouts);
}
m_SearchWindowProvider = ScriptableObject.CreateInstance<SearchWindowProvider>();

continue;
if (port.slot.slotReference.Equals(m_SearchWindowProvider.targetSlotReference))
{
port.RegisterCallback<PostLayoutEvent>(RepositionNode);
port.RegisterCallback<GeometryChangedEvent>(RepositionNode);
return;
}
}

static void RepositionNode(PostLayoutEvent evt)
static void RepositionNode(GeometryChangedEvent evt)
port.UnregisterCallback<PostLayoutEvent>(RepositionNode);
port.UnregisterCallback<GeometryChangedEvent>(RepositionNode);
var nodeView = port.node as MaterialNodeView;
if (nodeView == null)
return;

}
}
void ApplySerializewindowLayouts(PostLayoutEvent evt)
void ApplySerializewindowLayouts(GeometryChangedEvent evt)
UnregisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
UnregisterCallback<GeometryChangedEvent>(ApplySerializewindowLayouts);
if (m_FloatingWindowsLayout != null)
{

5
com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs


using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine.Experimental.UIElements.StyleEnums;
using Node = UnityEditor.Experimental.UIElements.GraphView.Node;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif
namespace UnityEditor.ShaderGraph.Drawing
{

{
var portInputView = new PortInputView(port.slot) { style = { positionType = PositionType.Absolute } };
m_PortInputContainer.Add(portInputView);
port.RegisterCallback<PostLayoutEvent>(evt => UpdatePortInput((ShaderPort)evt.target));
port.RegisterCallback<GeometryChangedEvent>(evt => UpdatePortInput((ShaderPort)evt.target));
}
}
}

正在加载...
取消
保存