public override void OnInspectorGUI() { base.OnInspectorGUI(); if (instance == null) { Awake(); } GUI.changed = false; Undo.RecordObject(instance, "Collectible"); EditorGUILayout.Space(); //EditorGUILayout.HelpBox("Editing Collectible component using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info); if (GUILayout.Button("Collectible Editor Window")) { CollectibleEditorWindow.Init(); } if (TDSEditor.IsPrefab(instance.gameObject)) { if (!TDSEditor.ExistInDB(instance)) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible by other editor.", MessageType.Warning); GUI.color = new Color(1f, 0.7f, .2f, 1f); if (GUILayout.Button("Add Prefab to Database")) { CollectibleEditorWindow.Init(); CollectibleEditorWindow.NewItem(instance); CollectibleEditorWindow.Init(); //call again to select the instance in editor window } GUI.color = Color.white; } EditorGUILayout.Space(); } EditorGUILayout.Space(); DrawFullEditor(); EditorGUILayout.Space(); DefaultInspector(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
void OnSelectionChange() { if (window == null) { return; } srlObj = null; selectedUnitList = new List <UnitAI>(); UnityEngine.Object[] filtered = Selection.GetFiltered(typeof(UnitAI), SelectionMode.Editable); for (int i = 0; i < filtered.Length; i++) { selectedUnitList.Add((UnitAI)filtered[i]); } //if no no relevent object is selected if (selectedUnitList.Count == 0) { SelectItem(); if (unitAIDB.unitList.Count > 0 && selectID >= 0) { UpdateObjectHierarchyList(unitAIDB.unitList[selectID].gameObject); } } else { //only one relevent object is selected if (selectedUnitList.Count == 1) { //if the selected object is a prefab and match the selected item in editor, do nothing if (selectID > 0 && selectedUnitList[0] == unitAIDB.unitList[selectID]) { UpdateObjectHierarchyList(selectedUnitList[0].gameObject); } //if the selected object doesnt match... else { //if the selected object existed in DB if (TDSEditor.ExistInDB(selectedUnitList[0])) { window.selectID = TDSEditor.GetUnitAIIndex(selectedUnitList[0].prefabID) - 1; UpdateObjectHierarchyList(selectedUnitList[0].gameObject); SelectItem(); } //if the selected object is not in DB else { selectID = -1; UpdateObjectHierarchyList(selectedUnitList[0].gameObject); } } } //selected multiple editable object else { selectID = -1; UpdateObjectHierarchyList(selectedUnitList[0].gameObject); } srlObj = new SerializedObject(filtered); } Repaint(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (instance == null) { Awake(); } GUI.changed = false; Undo.RecordObject(instance, "Player"); serializedObject.Update(); EditorGUILayout.Space(); cont = new GUIContent("Load Progress:", "Check to enable loading of progress made in leveling and perk unlocking from previous save"); instance.loadProgress = EditorGUILayout.Toggle(cont, instance.loadProgress); cont = new GUIContent("Save Progress:", "Check to enable saving of progress made in leveling and perk unlocking"); instance.saveProgress = EditorGUILayout.Toggle(cont, instance.saveProgress); cont = new GUIContent("Save Upon Change:", "Check to enable instant save upon any changes made\nOtherwise saving is only done player hits a save trigger"); if (instance.saveProgress) { instance.saveUponChange = EditorGUILayout.Toggle(cont, instance.saveUponChange); } else { EditorGUILayout.LabelField(cont, new GUIContent("-")); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); bool saveExisted = PlayerPrefs.HasKey("p" + instance.playerID + "_progress") | PlayerPrefs.HasKey("p" + instance.playerID + "_perk"); EditorGUILayout.LabelField("Save Existed: " + (saveExisted ? "Yes" : "No")); if (saveExisted && GUILayout.Button("Delete Save")) { instance.DeleteSave(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Editing the rest of UnitPlayer component using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info); if (GUILayout.Button("Unit Editor Window")) { UnitPlayerEditorWindow.Init(); } if (TDSEditor.IsPrefab(instance.gameObject)) { if (!TDSEditor.ExistInDB(instance)) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible by other editor.", MessageType.Warning); GUI.color = new Color(1f, 0.7f, .2f, 1f); if (GUILayout.Button("Add Prefab to Database")) { UnitPlayerEditorWindow.Init(); UnitPlayerEditorWindow.NewItem(instance); UnitPlayerEditorWindow.Init(); //call again to select the instance in editor window } GUI.color = Color.white; } } EditorGUILayout.Space(); DefaultInspector(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }