public virtual void DrawBlockName(Flowchart flowchart) { serializedObject.Update(); SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName"); //calc position as size of what we want to draw pushed up into the top bar of the inspector //Rect blockLabelRect = new Rect(45, -GUI.skin.window.padding.bottom - EditorGUIUtility.singleLineHeight * 2, 120, 16); //EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name")); //Rect blockNameRect = new Rect(45, blockLabelRect.y + EditorGUIUtility.singleLineHeight, 180, 16); //EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent("")); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Block Name"), EditorStyles.largeLabel); EditorGUI.BeginChangeCheck(); blockNameProperty.stringValue = EditorGUILayout.TextField(blockNameProperty.stringValue); if (EditorGUI.EndChangeCheck()) { // Ensure block name is unique for this Flowchart var block = target as Block; string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block); if (uniqueName != block.BlockName) { blockNameProperty.stringValue = uniqueName; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
public virtual void DrawBlockName(Flowchart flowchart) { serializedObject.Update(); SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName"); Rect blockLabelRect = new Rect(45, 5, 120, 16); EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name")); Rect blockNameRect = new Rect(45, 21, 180, 16); EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent("")); // Ensure block name is unique for this Flowchart var block = target as Block; string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block); if (uniqueName != block.BlockName) { blockNameProperty.stringValue = uniqueName; } serializedObject.ApplyModifiedProperties(); }
public virtual void DrawBlockName(Flowchart flowchart) { serializedObject.Update(); SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName"); Rect blockLabelRect = new Rect(45, 5, 120, 16); EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name")); Rect blockNameRect = new Rect(45, 21, 180, 16); EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent("")); // Ensure block name is unique for this Flowchart var block = target as Block; string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block); if (uniqueName != block.BlockName) { blockNameProperty.stringValue = uniqueName; } serializedObject.ApplyModifiedProperties(); }
internal Block PasteBlock(Flowchart flowchart) { var newBlock = FlowchartWindow.CreateBlock(flowchart, Vector2.zero); // Copy all command serialized properties // Copy references to match duplication behavior foreach (var command in commands) { var newCommand = Undo.AddComponent(flowchart.gameObject, command.type) as Command; CopyProperties(command.serializedObject, newCommand); newCommand.ItemId = flowchart.NextItemId(); newBlock.CommandList.Add(newCommand); } // Copy event handler if (eventHandler != null) { var newEventHandler = Undo.AddComponent(flowchart.gameObject, eventHandler.type) as EventHandler; CopyProperties(eventHandler.serializedObject, newEventHandler); newEventHandler.ParentBlock = newBlock; newBlock._EventHandler = newEventHandler; } // Copy block properties, but do not copy references because those were just assigned CopyProperties( block, newBlock, SerializedPropertyType.ObjectReference, SerializedPropertyType.Generic, SerializedPropertyType.ArraySize ); newBlock.BlockName = flowchart.GetUniqueBlockKey(block.FindProperty("blockName").stringValue + " (Copy)"); return newBlock; }