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(); } if (saveOnScopeEnd) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_SAVE)); } }
public void DrawConnectionOutputPointMark(NodeEvent eventSource, bool justConnecting, Event current) { if (scaleFactor != SCALE_MAX) { return; } var defaultPointTex = NodeGUIUtility.outputPointMarkConnectedTex; bool shouldDrawEnable = !(eventSource != null && eventSource.eventSourceNode != null && !ConnectionData.CanConnect(m_data, eventSource.eventSourceNode.Data) ); if (shouldDrawEnable && justConnecting && eventSource != null) { if (eventSource.eventSourceNode.Id != this.Id) { var connectionPoint = eventSource.point; if (connectionPoint.IsInput) { defaultPointTex = NodeGUIUtility.enablePointMarkTex; } } } var globalMousePosition = current.mousePosition; foreach (var point in m_data.OutputPoints) { var pointRegion = point.GetGlobalPointRegion(this); GUI.DrawTexture( pointRegion, defaultPointTex ); // eventPosition is contained by outputPointRect. if (pointRegion.Contains(globalMousePosition)) { if (current.type == EventType.MouseDown) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECT_STARTED, this, current.mousePosition, point)); } } } }
private void DoInspectorFilterGUI(NodeGUI node) { EditorGUILayout.HelpBox("Filter: Filter incoming assets by keywords and types. You can use regular expressions for keyword field.", MessageType.Info); UpdateNodeName(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { GUILayout.Label("Filter Settings:"); FilterEntry removing = null; for (int i = 0; i < node.Data.FilterConditions.Count; ++i) { var cond = node.Data.FilterConditions[i]; Action messageAction = null; using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("-", GUILayout.Width(30))) { removing = cond; } else { var newContainsKeyword = cond.FilterKeyword; GUIStyle s = new GUIStyle((GUIStyle)"TextFieldDropDownText"); using (new EditorGUILayout.HorizontalScope()) { newContainsKeyword = EditorGUILayout.TextField(cond.FilterKeyword, s, GUILayout.Width(120)); if (GUILayout.Button(cond.FilterKeytype, "Popup")) { var ind = i; // need this because of closure locality bug in unity C# NodeGUI.ShowFilterKeyTypeMenu( cond.FilterKeytype, (string selectedTypeStr) => { using (new RecordUndoScope("Modify Filter Type", node, true)){ node.Data.FilterConditions[ind].FilterKeytype = selectedTypeStr; } } ); } } if (newContainsKeyword != cond.FilterKeyword) { using (new RecordUndoScope("Modify Filter Keyword", node, true)){ cond.FilterKeyword = newContainsKeyword; // event must raise to propagate change to connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, node, Vector2.zero, cond.ConnectionPoint)); } } } } if (messageAction != null) { using (new GUILayout.HorizontalScope()) { messageAction.Invoke(); } } } // add contains keyword interface. if (GUILayout.Button("+")) { using (new RecordUndoScope("Add Filter Condition", node)){ node.Data.AddFilterCondition( AssetBundleGraphSettings.DEFAULT_FILTER_KEYWORD, AssetBundleGraphSettings.DEFAULT_FILTER_KEYTYPE); } } if (removing != null) { using (new RecordUndoScope("Remove Filter Condition", node, true)){ // event must raise to remove connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, removing.ConnectionPoint)); node.Data.RemoveFilterCondition(removing); } } } }
private void DoInspectorBundleConfiguratorGUI(NodeGUI node) { if (node.Data.BundleNameTemplate == null) { return; } EditorGUILayout.HelpBox("BundleConfigurator: Create asset bundle settings with given group of assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = DrawOverrideTargetToggle(node, node.Data.BundleNameTemplate.ContainsValueOf(currentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Bundle Name Template Setting", node, true)){ if (enabled) { node.Data.BundleNameTemplate[currentEditingGroup] = node.Data.BundleNameTemplate.DefaultValue; } else { node.Data.BundleNameTemplate.Remove(currentEditingGroup); } } }); using (disabledScope) { var bundleNameTemplate = EditorGUILayout.TextField("Bundle Name Template", node.Data.BundleNameTemplate[currentEditingGroup]).ToLower(); if (bundleNameTemplate != node.Data.BundleNameTemplate[currentEditingGroup]) { using (new RecordUndoScope("Change Bundle Name Template", node, true)){ node.Data.BundleNameTemplate[currentEditingGroup] = bundleNameTemplate; } } } } using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { GUILayout.Label("Variants:"); var variantNames = node.Data.Variants.Select(v => v.Name).ToList(); Variant removing = null; foreach (var v in node.Data.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; }; IntegratedGUIBundleConfigurator.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; } } } } } if (GUILayout.Button("+")) { using (new RecordUndoScope("Add Variant", node, true)){ node.Data.AddVariant(AssetBundleGraphSettings.BUNDLECONFIG_VARIANTNAME_DEFAULT); } } 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, removing.ConnectionPoint)); node.Data.RemoveVariant(removing); } } } }
/** * retrieve mouse events for this node in this AssetGraoh window. */ private void HandleNodeEvent() { 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_NODE_CONNECTION_OVERED, this, Event.current.mousePosition, null)); break; } /* * handling drag. */ case EventType.MouseDrag: { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_MOVING, 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: { ConnectionPointData result = IsOverConnectionPoint(Event.current.mousePosition); if (result != null) { if (scaleFactor == SCALE_MAX) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECT_STARTED, this, Event.current.mousePosition, result)); } break; } break; } } /* * retrieve mouse events for this node in|out of this AssetGraoh window. */ switch (Event.current.rawType) { case EventType.MouseUp: { bool eventRaised = false; // if mouse position is on the connection point, emit mouse raised event. Action <ConnectionPointData> raiseEventIfHit = (ConnectionPointData point) => { // Only one connectionPoint raise event at one mouseup event if (eventRaised) { return; } if (!IsValidInputConnectionPoint(point)) { return; } if (point.Region.Contains(Event.current.mousePosition)) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECTION_RAISED, this, Event.current.mousePosition, point)); eventRaised = true; return; } }; m_data.InputPoints.ForEach(raiseEventIfHit); m_data.OutputPoints.ForEach(raiseEventIfHit); if (!eventRaised) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_TOUCHED, this, Event.current.mousePosition, null)); } break; } } /* * right click to open Context menu */ if (scaleFactor == SCALE_MAX) { if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1)) { var menu = new GenericMenu(); MonoScript s = TypeUtility.LoadMonoScript(Data.ScriptClassName); if (s != null) { menu.AddItem( new GUIContent("Edit Script"), false, () => { AssetDatabase.OpenAsset(s, 0); } ); } menu.AddItem( new GUIContent("Delete"), false, () => { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CLOSE_TAPPED, this, Vector2.zero, null)); } ); menu.ShowAsContext(); Event.current.Use(); } } }
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)); }