public override void OnInspectorGUI() { InstructionBreadcrumbsDrawer.Draw(); var set = target as InstructionSet; var design = GUILayout.Button("Show Designer"); _toEdit = null; _toRemove = -1; EditorGUILayout.Space(); EditorHelper.Separator(Color.grey); EditorGUILayout.Space(); using (new UndoScope(serializedObject)) _instructions.DrawList(); if (_toEdit != null) { InstructionBreadcrumbs.Edit(_toEdit); } if (_toRemove >= 0) { Remove(set, _toRemove); } if (design) { Design(set); } }
public static void Draw(Rect position) { var back = new Rect(position.x, position.y + EditorGUIUtility.standardVerticalSpacing, 80, EditorGUIUtility.singleLineHeight); var root = new Rect(position.center.x - 40, position.y + EditorGUIUtility.standardVerticalSpacing, 80, EditorGUIUtility.singleLineHeight); var forward = new Rect(position.xMax - 80 - 5, position.y + EditorGUIUtility.standardVerticalSpacing, 80, EditorGUIUtility.singleLineHeight); if (InstructionBreadcrumbs.HasPreviousEntry()) { if (GUI.Button(back, EditorHelper.BackContent)) { InstructionBreadcrumbs.Back(); } } if (InstructionBreadcrumbs.HasRoot()) { if (GUI.Button(root, EditorHelper.RootContent)) { InstructionBreadcrumbs.Root(); } } if (InstructionBreadcrumbs.HasNextEntry()) { if (GUI.Button(forward, EditorHelper.ForwardContent)) { InstructionBreadcrumbs.Forward(); } } }
private void OnEnable() { InstructionBreadcrumbs.Reset(); var instructions = _instructions.Setup(serializedObject.FindProperty("Instructions"), null, null, false, true, false, true, true, DrawInstruction, RemoveInstruction); instructions.onAddDropdownCallback += AddInstructionDropdown; _instructionTypes = TypeFinder.GetDerivedTypes <Instruction>(""); foreach (var type in _instructionTypes.Types) { _addMenu.AddItem(new GUIContent(type.Name, "The type of instruction to create."), false, AddInstruction, type); } }
public static Instruction Draw(Rect position, InstructionSet set, Instruction currentInstruction, GUIContent label) { if (label != null) { position = EditorGUI.PrefixLabel(position, label); } var popup = GetPopup(set); var names = popup.GetRootNames(); var index = popup.GetIndex(currentInstruction); var left = currentInstruction != null ? new Rect(position.x, position.y, position.width * 0.5f, EditorGUIUtility.singleLineHeight) : position; using (var changes = new EditorGUI.ChangeCheckScope()) { index = EditorGUI.Popup(left, index, names); if (changes.changed) { currentInstruction = popup.GetInstruction(index); } } if (currentInstruction != null) { var edit = new Rect(left.xMax + 5, position.y, (position.width - left.width - 10) * 0.5f, EditorGUIUtility.singleLineHeight); var clear = new Rect(edit.xMax + 5, position.y, edit.width, edit.height); if (GUI.Button(edit, EditorHelper.EditContent)) { InstructionBreadcrumbs.Edit(currentInstruction); } if (GUI.Button(clear, EditorHelper.ClearContent)) { currentInstruction = null; } } return(currentInstruction); }