private void Inspect(TreeViewItem treeView, Vector2 position) { if (treeView is HierarchyNodeTree nodeTree) { ActionPopupWindow.ShowWindow(Vector2.zero, () => { CustomInspector.ShowInspector(new GraphEditorData(graph) { selected = nodeTree.node }); }, 300, 300).ChangePosition(position); } else if (treeView is HierarchyFunctionTree functionTree) { ActionPopupWindow.ShowWindow(Vector2.zero, () => { CustomInspector.ShowInspector(new GraphEditorData(graph) { selected = functionTree.function }); }, 300, 300).ChangePosition(position); } else if (treeView is HierarchyPropertyTree propertyTree) { ActionPopupWindow.ShowWindow(Vector2.zero, () => { CustomInspector.ShowInspector(new GraphEditorData(graph) { selected = propertyTree.property }); }, 300, 300).ChangePosition(position); } else if (treeView is HierarchyVariableTree variableTree) { ActionPopupWindow.ShowWindow(Vector2.zero, () => { CustomInspector.ShowInspector(new GraphEditorData(graph) { selected = variableTree.variable }); }, 300, 300).ChangePosition(position); } }
public override void OnInspectorGUI() { uNodeRoot root = target as uNodeRoot; EditorGUI.BeginDisabledGroup(uNodeEditorUtility.IsPrefab(root)); EditorGUI.BeginChangeCheck(); CustomInspector.DrawGraphInspector(root); if (EditorGUI.EndChangeCheck()) { uNodeEditor.GUIChanged(); } EditorGUI.EndDisabledGroup(); if (uNodeEditorUtility.IsPrefab(root)) { if (root is uNodeRuntime) { EditorGUILayout.HelpBox("Open Prefab to Edit Graph", MessageType.Info); } else { if (GUILayout.Button(new GUIContent("Open uNode Editor", "Open uNode Editor to edit this uNode"), EditorStyles.toolbarButton)) { uNodeEditor.ChangeTarget(target as uNodeRoot, true); } EditorGUILayout.HelpBox("Open uNode Editor to Edit values", MessageType.Info); } } else { if (GUILayout.Button(new GUIContent("Open uNode Editor", "Open uNode Editor to edit this uNode"), EditorStyles.toolbarButton)) { uNodeEditor.ChangeTarget(target as uNodeRoot, true); } } if (!Application.isPlaying && (root is uNodeRuntime || root is ISingletonGraph)) { var type = root.GeneratedTypeName.ToType(false); if (type != null) { EditorGUILayout.HelpBox("Run using Native C#", MessageType.Info); } else { EditorGUILayout.HelpBox("Run using Reflection", MessageType.Info); } } else if (Application.isPlaying && root is uNodeComponentSingleton singleton && (singleton.runtimeBehaviour != null || singleton.runtimeInstance != null)) { EditorGUI.DropShadowLabel(uNodeGUIUtility.GetRect(), "Runtime Component"); if (singleton.runtimeBehaviour == null) { uNodeGUIUtility.DrawVariablesInspector(singleton.runtimeInstance.Variables, singleton.runtimeInstance, null); } else if (singleton.runtimeBehaviour != null) { Editor editor = Editor.CreateEditor(singleton.runtimeBehaviour); if (editor != null) { editor.OnInspectorGUI(); } else { uNodeGUIUtility.ShowFields(singleton.runtimeBehaviour, singleton.runtimeBehaviour); } } } if (!Application.isPlaying && root is IIndependentGraph) { var system = GraphUtility.GetGraphSystem(root); if (system != null && system.allowAutoCompile && uNodeEditorUtility.IsPrefab(root)) { var actualGraph = root; if (GraphUtility.HasTempGraphObject(root.gameObject)) { actualGraph = GraphUtility.GetTempGraphObject(root); } uNodeGUIUtility.ShowField(new GUIContent("Compile to C#", "If true, the graph will be compiled to C# to run using native c# performance on build or in editor using ( Generate C# Scripts ) menu."), nameof(root.graphData.compileToScript), actualGraph.graphData, actualGraph); } } }
protected void Initialize(UGraphView owner) { this.owner = owner; this.AddToClassList("node-view"); if (!ShowExpandButton()) //Hides colapse button { m_CollapseButton.style.position = Position.Absolute; m_CollapseButton.style.width = 0; m_CollapseButton.style.height = 0; m_CollapseButton.visible = false; } base.expanded = true; RegisterCallback <MouseDownEvent>(evt => { var mPos = (evt.currentTarget as VisualElement).GetScreenMousePosition(evt.localMousePosition, graph.window); if (evt.button == 0 && evt.shiftKey && !evt.altKey) { ActionPopupWindow.ShowWindow(Vector2.zero, () => { CustomInspector.ShowInspector(new GraphEditorData(graph.editorData) { selected = targetNode }); }, 300, 300).ChangePosition(mPos); } }); RegisterCallback <MouseOverEvent>((e) => { for (int i = 0; i < inputPorts.Count; i++) { var edges = inputPorts[i].GetEdges(); foreach (var edge in edges) { if (edge == null) { continue; } if (edge.isProxy) { edge.edgeControl.visible = true; } } } for (int i = 0; i < outputPorts.Count; i++) { var edges = outputPorts[i].GetEdges(); foreach (var edge in edges) { if (edge == null) { continue; } if (edge.isProxy) { edge.edgeControl.visible = true; } } } }); RegisterCallback <MouseLeaveEvent>((e) => { for (int i = 0; i < inputPorts.Count; i++) { var edges = inputPorts[i].GetEdges(); foreach (var edge in edges) { if (edge == null) { continue; } if (edge.isProxy) { edge.edgeControl.visible = false; } } } for (int i = 0; i < outputPorts.Count; i++) { var edges = outputPorts[i].GetEdges(); foreach (var edge in edges) { if (edge == null) { continue; } if (edge.isProxy) { edge.edgeControl.visible = false; } } } }); RegisterCallback <GeometryChangedEvent>(evt => { if (evt.oldRect != Rect.zero && evt.oldRect.width != evt.newRect.width) { Teleport(new Rect(evt.newRect.x + (evt.oldRect.width - evt.newRect.width), evt.newRect.y, evt.newRect.width, evt.newRect.height)); } }); border = this.Q("node-border"); { //Flow inputs flowInputContainer = new VisualElement(); flowInputContainer.name = "flow-inputs"; flowInputContainer.AddToClassList("flow-container"); flowInputContainer.AddToClassList("input"); flowInputContainer.pickingMode = PickingMode.Ignore; border.Insert(0, flowInputContainer); } { //Flow outputs flowOutputContainer = new VisualElement(); flowOutputContainer.name = "flow-outputs"; flowOutputContainer.AddToClassList("flow-container"); flowOutputContainer.AddToClassList("output"); flowOutputContainer.pickingMode = PickingMode.Ignore; Add(flowOutputContainer); } controlsContainer = new VisualElement { name = "controls" }; mainContainer.Add(controlsContainer); titleIcon = new Image() { name = "title-icon" }; titleContainer.Add(titleIcon); titleIcon.SendToBack(); OnSetup(); }