internal void DrawNodeGUI(NodeGUIEditor nodeGUIEditor) { //JudgeName(); EditorGUI.BeginChangeCheck(); if (nodeDataDrawer != null) { nodeDataDrawer.OnInspectorGUI(this); } if (EditorGUI.EndChangeCheck()) { if (Controller != null) { Controller.Validate(this); Controller.Perform(); } EditorUtility.SetDirty(Data.Object); NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, this, Event.current.mousePosition, null)); if (ParentGraph) { EditorUtility.SetDirty(ParentGraph); } } }
protected override void CloseScope() { if (node != null) { node.ResetErrorStatus(); } NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_SAVE)); }
protected override void CloseScope() { if (node != null) { //node.UpdateNodeRect(); node.ResetErrorStatus(); NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, node)); } if (saveOnScopeEnd) { // NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_SAVE)); } }
public void DrawConnectionOutputPointMark(NodeEvent eventSource, bool justConnecting, Event current) { var defaultPointTex = NodeGUIUtility.pointMark; var lastColor = GUI.color; bool shouldDrawEnable = eventSource == null || eventSource.eventSourceNode != null; bool shouldDrawWithEnabledColor = shouldDrawEnable && justConnecting && eventSource != null && eventSource.eventSourceNode.Id != this.Id && eventSource.point.IsInput; var globalMousePosition = current.mousePosition; foreach (var point in m_data.OutputPoints) { var pointRegion = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this); //var pointRegion = point.GetGlobalPointRegion(this); if (shouldDrawWithEnabledColor && Controller.GetConnectType(eventSource.point, point) != null) { GUI.color = NGEditorSettings.GUI.COLOR_CAN_CONNECT; } else { GUI.color = (justConnecting) ? NGEditorSettings.GUI.COLOR_CAN_NOT_CONNECT : NGEditorSettings.GUI.COLOR_CONNECTED; } GUI.DrawTexture( pointRegion, defaultPointTex ); GUI.color = lastColor; // eventPosition is contained by outputPointRect. if (pointRegion.Contains(globalMousePosition)) { if (current.type == EventType.MouseDown) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, current.mousePosition, point)); } } } }
public RecordUndoScope(string message, NodeGUI node, bool saveOnScopeEnd) { this.node = node; this.saveOnScopeEnd = saveOnScopeEnd; NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_RECORDUNDO, message)); }
public RecordUndoScope(string message, NodeGUI node) { this.node = node; NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_RECORDUNDO, message)); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_bundleNameTemplate == null) { return; } EditorGUILayout.HelpBox("Configure Bundle From Group: Create asset bundle settings from incoming group of assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var newUseGroupAsVariantValue = GUILayout.Toggle(m_useGroupAsVariants, "Use input group as variants"); if (newUseGroupAsVariantValue != m_useGroupAsVariants) { using (new RecordUndoScope("Change Bundle Config", node, true)){ m_useGroupAsVariants = newUseGroupAsVariantValue; List <Variant> rv = new List <Variant>(m_variants); foreach (var v in rv) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, v))); RemoveVariant(node.Data, v); } onValueChanged(); } } EditorGUI.BeginDisabledGroup(newUseGroupAsVariantValue); #region DisableGroup //using (new EditorGUI.DisabledScope(newUseGroupAsVariantValue)) { GUILayout.Label("Variants:"); var variantNames = m_variants.Select(v => v.Name).ToList(); Variant removing = null; foreach (var v in m_variants) { using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("-", GUILayout.Width(30))) { removing = v; } else { GUIStyle s = new GUIStyle((GUIStyle)"TextFieldDropDownText"); Action makeStyleBold = () => { s.fontStyle = FontStyle.Bold; s.fontSize = 12; }; ValidateVariantName(v.Name, variantNames, makeStyleBold, makeStyleBold, makeStyleBold); var variantName = EditorGUILayout.TextField(v.Name, s); if (variantName != v.Name) { using (new RecordUndoScope("Change Variant Name", node, true)){ v.Name = variantName; UpdateVariant(node.Data, v); onValueChanged(); } } } } } if (GUILayout.Button("+")) { using (new RecordUndoScope("Add Variant", node, true)){ if (m_variants.Count == 0) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_DELETE_ALL_CONNECTIONS_TO_POINT, node, Vector2.zero, node.Data.InputPoints[0])); } AddVariant(node.Data, Model.Settings.BUNDLECONFIG_VARIANTNAME_DEFAULT); onValueChanged(); } } if (removing != null) { using (new RecordUndoScope("Remove Variant", node, true)){ // event must raise to remove connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, removing))); RemoveVariant(node.Data, removing); onValueChanged(); } } #endregion EditorGUI.EndDisabledGroup(); } //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_bundleNameTemplate.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Bundle Name Template Setting", node, true)){ if (enabled) { m_bundleNameTemplate[editor.CurrentEditingGroup] = m_bundleNameTemplate.DefaultValue; } else { m_bundleNameTemplate.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); EditorGUI.BeginDisabledGroup(disabledScope); //using (disabledScope) { var bundleNameTemplate = EditorGUILayout.TextField("Bundle Name Template", m_bundleNameTemplate[editor.CurrentEditingGroup]).ToLower(); if (bundleNameTemplate != m_bundleNameTemplate[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Bundle Name Template", node, true)){ m_bundleNameTemplate[editor.CurrentEditingGroup] = bundleNameTemplate; onValueChanged(); } } //} EditorGUI.EndDisabledGroup(); } }
//private bool IsValidInputConnectionPoint(Model.ConnectionPointData point) //{ // return m_data.Operation.Object.IsValidInputConnectionPoint(point); //} /** * retrieve mouse events for this node in this GraphEditor window. */ private void HandleNodeMouseEvent() { switch (Event.current.type) { /* * handling release of mouse drag from this node to another node. * this node doesn't know about where the other node is. the master only knows. * only emit event. */ case EventType.Ignore: { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_END, this, Event.current.mousePosition, null)); break; } /* * check if the mouse-down point is over one of the connectionPoint in this node. * then emit event. */ case EventType.MouseDown: { Model.ConnectionPointData result = IsOverConnectionPoint(Event.current.mousePosition); if (result != null) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, Event.current.mousePosition, result)); break; } else { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CLICKED, this, Event.current.mousePosition, null)); } break; } } /* * retrieve mouse events for this node in|out of this GraphTool window. */ switch (Event.current.rawType) { case EventType.MouseUp: { bool eventSent = false; // send EVENT_CONNECTION_ESTABLISHED event if MouseUp performed on ConnectionPoint Action <Model.ConnectionPointData> raiseEventIfHit = (Model.ConnectionPointData point) => { // Only one connectionPoint can send NodeEvent. if (eventSent) { return; } //// If InputConnectionPoint is not valid at this moment, ignore //if (!IsValidInputConnectionPoint(point)) //{ // return; //} if (point.Region.Contains(Event.current.mousePosition)) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_CONNECTION_ESTABLISHED, this, Event.current.mousePosition, point)); eventSent = true; return; } if (nodeDataDrawer != null) { nodeDataDrawer.OnClickNodeGUI(this, Event.current.mousePosition, IsOverConnectionPoint(Event.current.mousePosition)); } }; m_data.InputPoints.ForEach(raiseEventIfHit); m_data.OutputPoints.ForEach(raiseEventIfHit); break; } } /* * right click to open Context menu */ if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1)) { var menu = new GenericMenu(); if (nodeDataDrawer != null) { nodeDataDrawer.OnContextMenuGUI(menu, this); } menu.AddItem( new GUIContent("Delete"), false, () => { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_DELETE, this, Vector2.zero, null)); } ); menu.ShowAsContext(); Event.current.Use(); } }