浏览代码

Move framing shortcuts to GraphView.

/main
Patrick Fournier 7 年前
当前提交
19de8169
共有 3 个文件被更改,包括 4 次插入27 次删除
  1. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  2. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  3. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


m_GraphEditorView.onConvertToSubgraphClick += ToSubGraph;
m_GraphEditorView.onShowInProjectClick += PingAsset;
m_GraphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
m_GraphEditorView.RegisterCallback<AttachToPanelEvent, GraphEditorView>(OnEnterPanel, m_GraphEditorView);
m_GraphEditorView.RegisterCallback<DetachFromPanelEvent, GraphEditorView>(OnLeavePanel, m_GraphEditorView);
rootVisualContainer.Add(graphEditorView);
}

{
graphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.graphView.FrameAll();
}
void OnEnterPanel(AttachToPanelEvent e, GraphEditorView view)
{
VisualElement rootVisualContainer = UIElementsEntryPoint.GetRootVisualContainer(this);
rootVisualContainer.parent.AddManipulator(view.shortcutHandler);
}
void OnLeavePanel(DetachFromPanelEvent e, GraphEditorView view)
{
VisualElement rootVisualContainer = UIElementsEntryPoint.GetRootVisualContainer(this);
rootVisualContainer.parent.RemoveManipulator(view.shortcutHandler);
}
}
}

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


set { m_PreviewSystem = value; }
}
public ShortcutHandler shortcutHandler { get; set; }
public GraphEditorView(AbstractMaterialGraph graph, HelperMaterialGraphEditWindow container, string assetName)
{
AddStyleSheetPath("Styles/MaterialGraph");

m_GraphView = new MaterialGraphView { name = "GraphView", presenter = m_GraphPresenter };
m_GraphInspectorView = new GraphInspectorView(assetName, previewSystem, graph) { name = "inspector" };
m_GraphPresenter.onSelectionChanged += m_GraphInspectorView.UpdateSelection;
shortcutHandler = new ShortcutHandler(
new Dictionary<Event, ShortcutDelegate>
{
{ Event.KeyboardEvent("a"), m_GraphView.FrameAll },
{ Event.KeyboardEvent("o"), m_GraphView.FrameOrigin },
{ Event.KeyboardEvent("["), m_GraphView.FramePrev },
{ Event.KeyboardEvent("]"), m_GraphView.FrameNext }
});
content.Add(m_GraphView);
content.Add(m_GraphInspectorView);

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


AddStyleSheetPath("Styles/MaterialGraph");
serializeCopyPasteData = SerializeCopyPasteDataImplementation;
serializeGraphElements = SerializeGraphElementsImplementation;
isReframable = true;
}
public bool CanAddToNodeMenu(Type type)

PropagateSelection();
}
string SerializeCopyPasteDataImplementation(IEnumerable<GraphElement> elements)
string SerializeGraphElementsImplementation(IEnumerable<GraphElement> elements)
{
var graph = CreateCopyPasteGraph(elements);
return JsonUtility.ToJson(graph, true);

正在加载...
取消
保存