public override void OnInspectorGUI() { base.OnInspectorGUI(); // If the CostumizationManager is null, grab a reference to the CustomizationManager prefab. if (cm == null) { cm = (AssetDatabase.LoadAssetAtPath ("Assets/PreFabs/Managers/CustomizationManager.prefab", typeof(GameObject)) as GameObject).GetComponent <CustomizationManager>(); } // If the value of this object has not been assigned, assign it. if (value == null) { value = serializedObject.targetObject as CostumeData; } // If the add button is clicked, show the popup if (GUILayout.Button("Add New Piece")) { PopupWindow.Show(buttonRect, new NewCostumePopup(this)); } // If this costume is already in the manager, do not allow this button to be accessed EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(value.IsSelectable(cm)); // When clicked, add the costume to the manager if (GUILayout.Button("Add To Customization Manager")) { value.MakeSelectable(cm); // Refresh the manager EditorUtility.SetDirty(cm.gameObject); } EditorGUI.EndDisabledGroup(); // If this costume is not already in the manager, do not allow this button to be accessed EditorGUI.BeginDisabledGroup(!value.IsSelectable(cm)); // When clicked, remove the costume from the manager if (GUILayout.Button("Remove From Customization Manager")) { value.MakeUnselectable(cm); // Refresh the manager EditorUtility.SetDirty(cm.gameObject); } EditorGUI.EndDisabledGroup(); if (Event.current.type == EventType.Repaint) { buttonRect = GUILayoutUtility.GetLastRect(); } }