浏览代码

Created the functionality of creating Nodes directly when hitting spacebar. Simplified to not have to right click and click create node.

/main
Martin Thorzen 7 年前
当前提交
b73f8bc1
共有 1 个文件被更改,包括 19 次插入1 次删除
  1. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

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


{
MaterialGraphView m_GraphView;
GraphInspectorView m_GraphInspectorView;
private EditorWindow m_EditorWindow;
AbstractMaterialGraph m_Graph;
PreviewManager m_PreviewManager;

{
m_Graph = graph;
AddStyleSheetPath("Styles/MaterialGraph");
m_EditorWindow = editorWindow;
previewManager = new PreviewManager(graph);
var content = new VisualElement { name = "content" };

m_GraphInspectorView.AddManipulator(new Draggable(OnMouseDrag, true));
m_GraphView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
m_GraphInspectorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
m_GraphView.RegisterCallback<KeyDownEvent>(OnSpaceDown);
m_GraphView.Add(m_GraphInspectorView);

inspectorViewRect.height = Mathf.Min(inspectorViewRect.height, layout.height);
m_GraphInspectorView.layout = inspectorViewRect;
}
void OnSpaceDown(KeyDownEvent evt)
{
if( evt.keyCode == KeyCode.Space)
{
if (graphView.nodeCreationRequest == null)
return;
Vector2 referencePosition;
referencePosition = evt.imguiEvent.mousePosition;
Vector2 screenPoint = m_EditorWindow.position.position + referencePosition;
graphView.nodeCreationRequest(new NodeCreationContext() { screenMousePosition = screenPoint });
}
}
void OnMouseDrag(Vector2 mouseDelta)

正在加载...
取消
保存