private void PointButtons(BGCurvePointI point, int index, BGCurveSettings settings) { if (!settings.ShowPointMenu) { return; } var curve = point.Curve; //================== Copy if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGCopy123, PointCopyPaste.Instance.CopyTooltip)) { PointCopyPaste.Instance.Copy(point); } GUILayout.Space(2); //================== Paste if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGPaste123, PointCopyPaste.Instance.PasteTooltip)) { PointCopyPaste.Instance.Paste(point); } GUILayout.Space(2); //================== Add before if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Insert a point before this point")) { BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index); } GUILayout.Space(2); //=========================== Move Up if (index > 0 && BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGMoveUp123, "Move the point up")) { curve.Swap(index - 1, index); } GUILayout.Space(2); //=========================== Move Down if (index < curve.PointsCount - 1 && BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGMoveDown123, "Move the point down")) { curve.Swap(index, index + 1); } GUILayout.Space(2); //=========================== Delete if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGDelete123, "Delete the point")) { BGCurveEditor.DeletePoint(curve, index); if (editorSelection != null) { editorSelection.Remove(point); } GUIUtility.ExitGUI(); } }
private void PointButtons(BGCurvePoint point, int index, BGCurveSettings settings) { if (!settings.ShowPointMenu) { return; } var curve = point.Curve; //================== Add before if (BGEditorUtility.ButtonWithIcon(addBeforeTexture, "Insert a point before this point")) { curve.AddPoint(BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index); } GUILayout.Space(2); //=========================== Move Up if (index > 0 && BGEditorUtility.ButtonWithIcon(moveUpTexture, "Move the point up")) { curve.Swap(index - 1, index); } GUILayout.Space(2); //=========================== Move Down if (index < curve.PointsCount - 1 && BGEditorUtility.ButtonWithIcon(moveDownTexture, "Move the point down")) { curve.Swap(index, index + 1); } GUILayout.Space(2); //=========================== Delete if (BGEditorUtility.ButtonWithIcon(deleteTexture, "Delete the point")) { curve.Delete(index); editorSelection.Remove(point); GUIUtility.ExitGUI(); } }
private void InspectorTopSection() { if (Curve.PointsCount == 0) { EditorGUILayout.HelpBox( "1) Ctrl + LeftClick in scene view to add a point and snap it to " + "\r\n a) 3D mode: mesh with collider" + "\r\n b) 2D mode: curve's 2D plane." + "\r\n" + "\r\n2) Ctrl + Shift + LeftClick in Scene View to add a point unconditionally at some distance, specified in the settings." + "\r\n" + "\r\n3) Hold control over existing point or selection to access Scene View menu" + "\r\n" + "\r\n4) Hold shift + drag to use rectangular selection in Scene View" , MessageType.Info); } EditorGUILayout.PropertyField(closedProperty); EditorGUILayout.PropertyField(mode2DProperty); BGEditorUtility.Horizontal(() => { EditorGUILayout.PropertyField(controlTypeProperty); if (!BGEditorUtility.ButtonWithIcon(convertAll2D, "Convert control types for all existing points ", 44)) { return; } var settings = Settings; foreach (var point in Curve.Points.Where(point => point.ControlType != settings.ControlType)) { point.ControlType = settings.ControlType; } }); }
// ================================================================================ Inspector public override void OnInspectorGui() { var settings = Settings; editorSelection.Reset(); // ======================================== Top section InspectorTopSection(); // ======================================== Points GUILayout.Space(5); if (Curve.PointsCount > 0) { BGEditorUtility.VerticalBox(() => { var temp = BGCurveSettingsForEditor.DisableInspectorPointMenu; BGCurveSettingsForEditor.DisableInspectorPointMenu = BGEditorUtility.ButtonOnOff(ref temp, "Points menu [" + Curve.PointsCount + "]", "Show points in Editor inspector", HiddenPointMenuColor, new GUIContent("Show", "Click to show points menu"), new GUIContent("Hide", "Click to hide points menu"), () => { const string title = "Reverse points"; if (!GUILayout.Button(new GUIContent(title, "Reverse all points, but keep curve intact"))) { return; } if (Curve.PointsCount < 2) { BGEditorUtility.Inform(title, "There should be at least 2 points. Curve has " + Curve.PointsCount); return; } if (!BGEditorUtility.Confirm(title, "Are you sure you want to reverse the order of " + Curve.PointsCount + " points? Curve will remain intact.", "Reverse")) { return; } Curve.Reverse(); }); //show points! if (!BGCurveSettingsForEditor.DisableInspectorPointMenu) { SwapVector2Labels(Curve.Mode2D, () => Curve.ForEach((point, index, count) => editorPoint.OnInspectorGui(point, index, settings))); } }); // ======================================== Selections operations editorSelection.InspectorSelectionOperations(); //warning BGEditorUtility.HelpBox("Selection mode is on", MessageType.Warning, !editorSelection.Changed && editorSelection.HasSelected()); } else { BGEditorUtility.HorizontalBox(() => { EditorGUILayout.LabelField("No points!"); if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Add new point at (0,0,0) local coordinates")) { BGCurveEditor.AddPoint(Curve, new BGCurvePoint(Curve, Vector3.zero, settings.ControlType, Vector3.right, Vector3.left), 0); } }); } if (!editorSelection.Changed) { return; } Editor.Repaint(); SceneView.RepaintAll(); }
private void InspectorTopSection() { if (Curve.PointsCount == 0) { EditorGUILayout.HelpBox( "1) Ctrl + LeftClick in scene view to add a point and snap it to " + "\r\n a) 3D mode: mesh with collider" + "\r\n b) 2D mode: curve's 2D plane." + "\r\n" + "\r\n2) Ctrl + Shift + LeftClick in Scene View to add a point unconditionally at some distance, specified in the settings." + "\r\n" + "\r\n3) Hold control over existing point or selection to access Scene View menu" + "\r\n" + "\r\n4) Hold shift + drag to use rectangular selection in Scene View" + "\r\n" + "\r\n5) Ctrl + LeftClick over existing spline to insert a point" , MessageType.Info); } try { // Curve's block BGEditorUtility.VerticalBox(() => { //closed EditorGUILayout.PropertyField(closedProperty); //point's store mode BGEditorUtility.Horizontal(() => { EditorGUILayout.PropertyField(pointsModeProperty); BGEditorUtility.DisableGui(() => { BGEditorUtility.Assign(ref syncContent, () => new GUIContent("Sync", "Sort points Game Objects and update names")); if (!GUILayout.Button(syncContent)) { return; } BGPrivateField.Invoke(Curve, BGCurve.MethodSetPointsNames); }, !BGCurve.IsGoMode(Curve.PointsMode)); }); //2D mode BGEditorUtility.Horizontal(() => { EditorGUILayout.PropertyField(mode2DProperty); BGEditorUtility.DisableGui(() => { if (!GUILayout.Button("Apply", GUI.skin.button, GUILayout.Width(80))) { return; } Curve.FireBeforeChange(BGCurve.Event2D); Curve.Apply2D(Curve.Mode2D); Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.Event2D)); }, mode2DProperty.enumValueIndex == 0); }); //snapping BGEditorUtility.VerticalBox(() => { BGEditorUtility.Horizontal(() => { EditorGUILayout.PropertyField(snapTypeProperty); BGEditorUtility.DisableGui(() => { if (!GUILayout.Button("Apply", GUI.skin.button, GUILayout.Width(80))) { return; } Curve.FireBeforeChange(BGCurve.EventSnapType); Curve.ApplySnapping(); Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Snap, BGCurve.EventSnapType)); }, snapTypeProperty.enumValueIndex == 0); }); if (snapTypeProperty.enumValueIndex == 0) { return; } EditorGUILayout.PropertyField(snapAxisProperty); EditorGUILayout.PropertyField(snapDistanceProperty); EditorGUILayout.PropertyField(snapTriggerInteractionProperty); EditorGUILayout.PropertyField(snapToBackFacesProperty); BGEditorUtility.LayerMaskField("Snap Layer Mask", Curve.SnapLayerMask, i => { Curve.FireBeforeChange(BGCurve.EventSnapTrigger); Curve.SnapLayerMask = i; Curve.ApplySnapping(); Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Snap, BGCurve.EventSnapTrigger)); }); EditorGUILayout.PropertyField(snapMonitoringProperty); if (Curve.SnapMonitoring && Curve.SnapType != BGCurve.SnapTypeEnum.Off) { EditorGUILayout.HelpBox("You enabled snap monitoring, which monitor environment every frame and snap to it. Be aware, this is a very costly function", MessageType.Warning); } }); //event mode EditorGUILayout.PropertyField(eventModeProperty); //force update EditorGUILayout.PropertyField(forceChangedEventModeProperty); //convert control type BGEditorUtility.Horizontal(() => { EditorGUILayout.PropertyField(controlTypeProperty); if (!BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGConvertAll123, "Convert control types for all existing points ", 44)) { return; } var settings = Settings; foreach (var point in Curve.Points.Where(point => point.ControlType != settings.ControlType)) { point.ControlType = settings.ControlType; } }); }); } catch (BGEditorUtility.ExitException) { GUIUtility.ExitGUI(); } }
//OnInspectorGui for selection public void InspectorSelectionOperations() { BGEditorUtility.VerticalBox(() => { // ================================================ Global operations BGEditorUtility.HorizontalBox(() => { BGEditorUtility.SwapLabelWidth(80, () => EditorGUILayout.LabelField("Selected (" + points.Count + ")")); if (BGEditorUtility.ButtonWithIcon(deleteTexture, "Delete selected points")) { if (!DeleteSelected()) { return; } } GUILayout.Space(4); if (BGEditorUtility.ButtonWithIcon(selectAllTexture, "Select all points", 35)) { Changed = Changed || points.Count != curve.PointsCount; points.Clear(); foreach (var point1 in curve.Points) { points.Add(point1); } } GUILayout.Space(4); if (BGEditorUtility.ButtonWithIcon(deselectAllTexture, "Deselect all points", 35)) { Clear(); } }); // ================================================ Selections operations // skip mouse buttons events which change selection if (Changed) { return; } GUILayout.Space(5); if (HasSelected()) { BGEditorUtility.SwapGuiBackgroundColor(SelectedBackgroundColor, () => { BGEditorUtility.VerticalBox(() => { var averagePositionSelected = GetAveragePosition(); // ===================================================== Control handles BGEditorUtility.Horizontal(() => { controlType = (BGCurvePoint.ControlTypeEnum)EditorGUILayout.EnumPopup("Controls", controlType); if (!BGEditorUtility.ButtonWithIcon(convertAll2D, "Set control type for all selected points", 44)) { return; } SetControlTypeForSelected(controlType); }); // ===================================================== Average positions & delete BGEditorUtility.Vector3Field("Average position", "Average points position. Change several points positions at once, keeping distance difference intact", averagePositionSelected, newAverage => { var delta = newAverage - averagePositionSelected; curve.Transaction(() => { foreach (var point in points) { point.PositionWorld += delta; } }); }); // ===================================================== Set position directly BGEditorUtility.Vector3Field("Set position", "Set points position directly", averagePositionSelected, newPosition => { curve.Transaction(() => { if (BGEditorUtility.AnyChange(averagePositionSelected.x, newPosition.x)) { SetX(newPosition.x); } if (BGEditorUtility.AnyChange(averagePositionSelected.y, newPosition.y)) { SetY(newPosition.y); } if (BGEditorUtility.AnyChange(averagePositionSelected.z, newPosition.z)) { SetZ(newPosition.z); } }); }); // ===================================================== Set control positions directly var count = 0; var averageControl1Sum = Vector3.zero; var averageControl2Sum = Vector3.zero; foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) { count++; averageControl1Sum += point.ControlFirstLocal; averageControl2Sum += point.ControlSecondLocal; } if (count == 0) { return; } //has points with bezier controls BGEditorUtility.Vector3Field("Set Control 1", "Set 1st control position directly", averageControl1Sum / count, newPosition => { curve.Transaction( () => { foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) { point.ControlFirstLocal = newPosition; } }); }); BGEditorUtility.Vector3Field("Set Control 2", "Set 2nd control position directly", averageControl2Sum / count, newPosition => { curve.Transaction( () => { foreach (var point in points.Where(point => point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)) { point.ControlSecondLocal = newPosition; } }); }); }); }); } else { BGEditorUtility.HelpBox("Hold shift to use rectangular selection\r\nClick or click+drag over tick icons to (de)select points", MessageType.Info, curve.PointsCount > 0); } }); }
private void HeaderUi(int level, bool hasError) { var color = MyTree.GetColor(level, Collapsed, () => new Color(0, 0, 0, 0)); BGEditorUtility.SwapGuiBackgroundColor(color, () => { BGEditorUtility.Horizontal(headerBoxStyle, () => { BGEditorUtility.Indent(1, () => { var content = new GUIContent(descriptor == null ? Cc.GetType().Name : descriptor.Name + " (" + BGEditorUtility.Trim(Cc.CcName, 10) + ")", descriptor == null ? null : descriptor.Description); var width = headerFoldoutStyle.CalcSize(content).x + 16; BGEditorUtility.SwapLabelWidth((int)width, () => { //foldout (we dont use layout version cause it does not support clickin on labels) Collapsed = EditorGUI.Foldout( GUILayoutUtility.GetRect(width, 16f), Collapsed, content, true, Cc.enabled ? headerFoldoutStyle : headerFoldoutStyleDisabled); }); }); GUILayout.FlexibleSpace(); // status(error or Ok) EditorGUI.LabelField(GUILayoutUtility.GetRect(70, 16, EditorStyles.label), hasError ? "Error" : "Ok.", hasError ? errorStyle : okStyle); //help url if (!String.IsNullOrEmpty(Cc.HelpURL)) { if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGHelp123, "Open help in the browser")) { Application.OpenURL(Cc.HelpURL); } EditorGUILayout.Separator(); } //change visibility if (BGEditorUtility.ButtonWithIcon(Cc.Hidden ? BGBinaryResources.BGHiddenOn123 : BGBinaryResources.BGHiddenOff123, "Hide/Show properties")) { Cc.Hidden = !Cc.Hidden; } EditorGUILayout.Separator(); //change name if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGCcEditName123, "Change the name")) { BGCcChangeNameWindow.Open(Cc); } EditorGUILayout.Separator(); //add a child if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Add a component, which is dependant on this component")) { BGCcAddWindow.Open(MyTree.Curve, type => { //cache some data var gameObject = Cc.Curve.gameObject; var oldComponents = gameObject.GetComponents <BGCc>(); var currentCcType = Cc.GetType(); //add var addedCc = AddComponent(MyTree.Curve, type); if (addedCc == null) { return; } //we need to process all the way up to the Cc and link Ccs to right (newly created) parents var parentClass = addedCc.GetParentClass(); var recursionLimit = 16; var cc = addedCc; while (parentClass != null && recursionLimit-- > 0) { if (currentCcType == parentClass) { //we reached the current Cc cc.SetParent(Cc); break; } //going up var possibleParents = gameObject.GetComponents(parentClass); var parent = possibleParents.Where(possibleParent => !oldComponents.Contains(possibleParent)).Cast <BGCc>().FirstOrDefault(); if (parent == null) { break; } cc.SetParent(parent); cc = parent; parentClass = cc.GetParentClass(); } }, Cc.GetType()); } EditorGUILayout.Separator(); //enable/disable if (BGEditorUtility.ButtonWithIcon(Cc.enabled ? BGBinaryResources.BGTickYes123 : BGBinaryResources.BGTickNo123, "Enable/disable a component")) { Enable(!Cc.enabled); } EditorGUILayout.Separator(); //delete if (!BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGDelete123, "Remove this component")) { return; } //remove Delete(); EditorUtility.SetDirty(MyTree.Curve.gameObject); //not sure how to make proper exit throw new BGEditorUtility.ExitException(); }); }); }
// ================================================================================ Inspector public override void OnInspectorGui() { BGEditorUtility.Assign(ref whiteTexture, () => BGEditorUtility.Texture1X1(Color.white)); components = Curve.GetComponents <BGCc>(); var length = components.Length; tree.Refresh(components); if (tree.InitException != null) { EditorGUILayout.HelpBox("There was an error initializing editors for component's Tree View: " + tree.InitException.Message + "\r\n\r\nYou still can use default Unity's editors for components below.", MessageType.Error); return; } var hasError = HasError; var hasWarning = HasWarning; BGEditorUtility.HorizontalBox(() => { EditorGUILayout.LabelField("Components: " + length + " (" + (hasError ? "Error" : "Ok") + ")"); GUILayout.FlexibleSpace(); // turn on/off handles var handlesOff = BGCurveSettingsForEditor.CcInspectorHandlesOff; if (BGEditorUtility.ButtonWithIcon( handlesOff ? BGBinaryResources.BGHandlesOff123 : BGBinaryResources.BGHandlesOn123, "Turn on/off handles settings in Inspector")) { BGCurveSettingsForEditor.CcInspectorHandlesOff = !BGCurveSettingsForEditor.CcInspectorHandlesOff; } EditorGUILayout.Separator(); // turn on/off colored tree if (BGEditorUtility.ButtonWithIcon(customEditorsOn ? BGBinaryResources.BGOn123: BGBinaryResources.BGOff123, "Use custom UI for components (colored tree) and hide standard unity editors for components")) { customEditorsOn = !customEditorsOn; tree.Refresh(null, true); } EditorGUILayout.Separator(); if (length > 0) { // collapse/expand if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGCollapseAll123, "Collapse all components")) { tree.ExpandCollapseAll(true); } EditorGUILayout.Separator(); if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGExpandAll123, "Expand all components")) { tree.ExpandCollapseAll(false); } EditorGUILayout.Separator(); // delete all Ccs if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGDelete123, "Delete all components") && BGEditorUtility.Confirm("Delete", "Are you sure you want to delete " + length + " component(s)?", "Delete")) { tree.Delete(); } EditorGUILayout.Separator(); } //add new Cc if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Add new component")) { BGCcAddWindow.Open(Curve, type => AddComponent(Curve, type)); } }); if (length > 0) { // warnings/errors if (hasWarning || hasError) { for (var i = 0; i < components.Length; i++) { var component = components[i]; var name = (component.Descriptor != null ? component.Descriptor.Name + " " : "") + component.CcName; var error = component.Error; if (!string.IsNullOrEmpty(error)) { BGEditorUtility.HelpBox("Component error [" + name + "]: " + error, MessageType.Error); } var warning = component.Warning; if (!string.IsNullOrEmpty(warning)) { BGEditorUtility.HelpBox("Component warning [" + name + "]: " + warning, MessageType.Warning); } } } else { BGEditorUtility.HelpBox("No warnings or errors", MessageType.Info); } // tree GUI tree.OnInspectorGui(); } else { EditorGUILayout.HelpBox( "Hit the Plus icon to add a component" + "\r\n" + "\r\n" + "Components allows to add functionality without any scripting." , MessageType.Info); } if (hasError ^ HasError || hasWarning ^ HasWarning) { EditorApplication.RepaintHierarchyWindow(); } }
public override void OnInspectorGUI() { //adjust math if needed AdjustMath(BGPrivateField.GetSettings(Curve), Math); //styles BGEditorUtility.Assign(ref stickerStyle, () => new GUIStyle("Label") { fontSize = 18, alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState { textColor = Color.white } }); BGEditorUtility.Assign(ref settingsTexture, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSettingsIcon123)); serializedObject.Update(); // =========== Header DrawLogo(); // =========== lock view BGEditorUtility.Horizontal(() => { var temp = BGCurveSettingsForEditor.LockView; BGCurveSettingsForEditor.LockView = BGEditorUtility.ButtonOnOff(ref temp, "Lock view", "Disable selection of other objects in the scene", LockViewActiveColor, new GUIContent("Turn Off", "Click to turn this mode off"), new GUIContent("Turn On", "Click to turn this mode on")); if (BGEditorUtility.ButtonWithIcon(settingsTexture, "Open BGCurve Editor Settings", 24, 24)) { BGCurveSettingsForEditorWindow.Open(); } }); //warning BGEditorUtility.HelpBox("You can not chose another objects in the scene, except points.\r\n Use rectangular selection without pressing shift", MessageType.Warning, BGCurveSettingsForEditor.LockView, () => GUILayout.Space(8)); // =========== Tabs if (BGCurveSettingsForEditor.CurrentTab < 0 || BGCurveSettingsForEditor.CurrentTab > headers.Length - 1) { BGCurveSettingsForEditor.CurrentTab = 0; } BGCurveSettingsForEditor.CurrentTab = GUILayout.Toolbar(BGCurveSettingsForEditor.CurrentTab, headers, GUILayout.Height(ToolBarHeight)); //do not move this method(GUILayoutUtility.GetLastRect() is used) ShowStickers(); editors[BGCurveSettingsForEditor.CurrentTab].OnInspectorGui(); if (!GUI.changed) { return; // if no change- return } foreach (var editor in editors) { editor.OnBeforeApply(); } serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(Curve); foreach (var editor in editors) { editor.OnApply(); } transformMonitor.Check(); }
private void HeaderUi(int level, bool hasError) { var color = MyTree.GetColor(level, Collapsed, () => new Color(0, 0, 0, 0)); BGEditorUtility.SwapGuiBackgroundColor(color, () => { BGEditorUtility.Horizontal(headerBoxStyle, () => { BGEditorUtility.Indent(1, () => { var content = new GUIContent(descriptor == null ? Cc.GetType().Name : descriptor.Name + " (" + BGEditorUtility.Trim(Cc.CcName, 10) + ")", descriptor == null ? null : descriptor.Description); var width = headerFoldoutStyle.CalcSize(content).x + 16; BGEditorUtility.SwapLabelWidth((int)width, () => { //foldout (we dont use layout version cause it does not support clickin on labels) Collapsed = EditorGUI.Foldout( GUILayoutUtility.GetRect(width, 16f), Collapsed, content, true, Cc.enabled ? headerFoldoutStyle : headerFoldoutStyleDisabled); }); }); GUILayout.FlexibleSpace(); // status(error or Ok) EditorGUI.LabelField(GUILayoutUtility.GetRect(70, 16, EditorStyles.label), hasError ? "Error" : "Ok.", hasError ? errorStyle : okStyle); //help url if (!String.IsNullOrEmpty(Cc.HelpURL)) { if (BGEditorUtility.ButtonWithIcon(helpTexture, "Open help in the browser")) { Application.OpenURL(Cc.HelpURL); } EditorGUILayout.Separator(); } //change name if (BGEditorUtility.ButtonWithIcon(changeNameTexture, "Change the name")) { BGCcChangeNameWindow.Open(Cc); } EditorGUILayout.Separator(); //add child if (BGEditorUtility.ButtonWithIcon(addTexture, "Add a component, which is dependant on this component")) { BGCcAddWindow.Open(MyTree.Curve, type => { var bgCc = AddComponent(MyTree.Curve, type); bgCc.SetParent(Cc); }, Cc.GetType()); } EditorGUILayout.Separator(); //enable/disable if (BGEditorUtility.ButtonWithIcon(Cc.enabled ? enabledTexture : disabledTexture, "Enable/disable a component")) { Enable(!Cc.enabled); } EditorGUILayout.Separator(); //delete if (!BGEditorUtility.ButtonWithIcon(deleteTexture, "Remove this component")) { return; } //remove Delete(); EditorUtility.SetDirty(MyTree.Curve.gameObject); //not sure how to make proper exit throw new ExitException(); }); }); }