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 EditorGUI.DisabledScope DrawOverrideTargetToggle(NodeGUI node, bool status, Action <bool> onStatusChange) { if (currentEditingGroup == BuildTargetUtility.DefaultTarget) { return(new EditorGUI.DisabledScope(false)); } bool newStatus = GUILayout.Toggle(status, "Override for " + NodeGUIUtility.GetPlatformButtonFor(currentEditingGroup).ui.tooltip); if (newStatus != status && onStatusChange != null) { onStatusChange(newStatus); } return(new EditorGUI.DisabledScope(!newStatus)); }
public void DrawConnectionOutputPointMark(NodeEvent eventSource, bool justConnecting, Event current) { var defaultPointTex = NodeGUIUtility.pointMark; var lastColor = GUI.color; bool shouldDrawEnable = !(eventSource != null && eventSource.eventSourceNode != null && !Model.ConnectionData.CanConnect(m_data, eventSource.eventSourceNode.Data) ); 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 = point.GetGlobalPointRegion(this); if (shouldDrawWithEnabledColor) { GUI.color = Model.Settings.GUI.COLOR_CAN_CONNECT; } else { GUI.color = (justConnecting) ? Model.Settings.GUI.COLOR_CAN_NOT_CONNECT : Model.Settings.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 override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Split By Filter: Split incoming assets by filter conditions.", MessageType.Info); editor.UpdateNodeName(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { GUILayout.Label("Filter Settings:"); FilterEntry removing = null; for (int i = 0; i < m_filter.Count; ++i) { var cond = m_filter[i]; Action messageAction = null; using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("-", GUILayout.Width(30))) { removing = cond; } else { IFilter filter = cond.Instance.Object; if (filter == null) { using (new GUILayout.VerticalScope()) { EditorGUILayout.HelpBox(string.Format("Failed to deserialize assigned filter({0}). Please select valid class.", cond.Instance.ClassName), MessageType.Error); if (GUILayout.Button(cond.Instance.ClassName, "Popup", GUILayout.MinWidth(150f))) { var map = FilterUtility.GetAttributeAssemblyQualifiedNameMap(); NodeGUI.ShowTypeNamesMenu(cond.Instance.ClassName, map.Keys.ToList(), (string selectedGUIName) => { using (new RecordUndoScope("Change Filter Setting", node)) { var newFilter = FilterUtility.CreateFilter(selectedGUIName); cond.Instance = new FilterInstance(newFilter); onValueChanged(); } } ); } } } else { cond.Instance.Object.OnInspectorGUI(() => { using (new RecordUndoScope("Change Filter Setting", node)) { cond.Instance.Save(); UpdateFilterEntry(node.Data, cond); // event must raise to propagate change to connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, node, Vector2.zero, GetConnectionPoint(node.Data, cond))); onValueChanged(); } }); } } } if (messageAction != null) { using (new GUILayout.HorizontalScope()) { messageAction.Invoke(); } } } // add contains keyword interface. if (GUILayout.Button("+")) { var map = FilterUtility.GetAttributeAssemblyQualifiedNameMap(); if (map.Keys.Count > 1) { GenericMenu menu = new GenericMenu(); foreach (var name in map.Keys) { var guiName = name; menu.AddItem(new GUIContent(guiName), false, () => { using (new RecordUndoScope("Add Filter Condition", node)){ var filter = FilterUtility.CreateFilter(guiName); AddFilterCondition(node.Data, filter); onValueChanged(); } }); } menu.ShowAsContext(); } else { using (new RecordUndoScope("Add Filter Condition", node)){ AddFilterCondition(node.Data, new FilterByNameAndType()); onValueChanged(); } } } 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, GetConnectionPoint(node.Data, removing))); RemoveFilterCondition(node.Data, removing); onValueChanged(); } } } }
/** * 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; } }; 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(); Data.Operation.Object.OnContextMenuGUI(menu); menu.AddItem( new GUIContent("Delete"), false, () => { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_DELETE, 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)); }
private void DrawGeneratorSetting( GeneratorEntry entry, NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { var generator = entry.m_instance.Get <IAssetGenerator>(editor.CurrentEditingGroup); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var newName = EditorGUILayout.TextField("Name", entry.m_name); if (newName != entry.m_name) { using (new RecordUndoScope("Change Name", node, true)) { entry.m_name = newName; UpdateGeneratorEntry(node.Data, entry); // event must raise to propagate change to connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, node, Vector2.zero, GetConnectionPoint(node.Data, entry))); onValueChanged(); } } var map = AssetGeneratorUtility.GetAttributeAssemblyQualifiedNameMap(); if (map.Count > 0) { using (new GUILayout.HorizontalScope()) { GUILayout.Label("AssetGenerator"); var guiName = AssetGeneratorUtility.GetGUIName(entry.m_instance.ClassName); if (GUILayout.Button(guiName, "Popup", GUILayout.MinWidth(150f))) { var builders = map.Keys.ToList(); if (builders.Count > 0) { NodeGUI.ShowTypeNamesMenu(guiName, builders, (string selectedGUIName) => { using (new RecordUndoScope("Change AssetGenerator class", node, true)) { generator = AssetGeneratorUtility.CreateGenerator(selectedGUIName); entry.m_instance.Set(editor.CurrentEditingGroup, generator); onValueChanged(); } } ); } } MonoScript s = TypeUtility.LoadMonoScript(entry.m_instance.ClassName); using (new EditorGUI.DisabledScope(s == null)) { if (GUILayout.Button("Edit", GUILayout.Width(50))) { AssetDatabase.OpenAsset(s, 0); } } } } else { if (!string.IsNullOrEmpty(entry.m_instance.ClassName)) { EditorGUILayout.HelpBox( string.Format( "Your AssetGenerator script {0} is missing from assembly. Did you delete script?", entry.m_instance.ClassName), MessageType.Info); } else { string[] menuNames = Model.Settings.GUI_TEXT_MENU_GENERATE_ASSETGENERATOR.Split('/'); EditorGUILayout.HelpBox( string.Format( "You need to create at least one AssetGenerator script to use this node. To start, select {0}>{1}>{2} menu and create new script from template.", menuNames[1], menuNames[2], menuNames[3] ), MessageType.Info); } } GUILayout.Space(10f); editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope()) { var disabledScope = editor.DrawOverrideTargetToggle(node, entry.m_instance.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { if (enabled) { entry.m_instance.CopyDefaultValueTo(editor.CurrentEditingGroup); } else { entry.m_instance.Remove(editor.CurrentEditingGroup); } onValueChanged(); }); using (disabledScope) { if (generator != null) { Action onChangedAction = () => { using (new RecordUndoScope("Change AssetGenerator Setting", node)) { entry.m_instance.Set(editor.CurrentEditingGroup, generator); onValueChanged(); } }; generator.OnInspectorGUI(onChangedAction); } } } GUILayout.Space(4); if (GUILayout.Button("Remove Generator")) { m_removingEntry = entry; } } }
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(); } } 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(); } } } } //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(); } }); 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(); } } } } }