void EditElement(InventoryElement inventoryElement) { if (inventoryElement != null) { GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.name = EditorGUILayout.TextField("Name", inventoryElement.name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.description = EditorGUILayout.TextField("Description", inventoryElement.description); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.gameObject = EditorGUILayout.ObjectField("GameObject", inventoryElement.gameObject, typeof(GameObject), true) as GameObject; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.isStackable = EditorGUILayout.Toggle("Is Stackable", inventoryElement.isStackable); GUILayout.EndHorizontal(); if (inventoryElement.isStackable) { GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.maxStack = EditorGUILayout.IntField("Max Stack", inventoryElement.maxStack); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.nameColor = EditorGUILayout.ColorField("Name Tooltip Color", inventoryElement.nameColor); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.descriptionColor = EditorGUILayout.ColorField("Description Tooltip Color", inventoryElement.descriptionColor); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.icon = EditorGUILayout.ObjectField("Icon", inventoryElement.icon, typeof(Texture), true) as Texture; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); inventoryElement.windowActionFoldout = EditorGUILayout.Foldout(inventoryElement.windowActionFoldout, "Action Management"); GUILayout.EndHorizontal(); if (inventoryElement.windowActionFoldout) { GUILayout.BeginHorizontal(); GUILayout.Space(30); actionInfoFoldout = EditorGUILayout.Foldout(actionInfoFoldout, "Info"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(30); if (actionInfoFoldout) { EditorGUILayout.HelpBox("When you choose an Object for an action, make sure you choose an Object in the current scene" + " if you need to work with an instance of a script. Example: If you need to affect your character's health, then " + "select the object that has the Health script in the Scene as opposed to the Assets.", MessageType.Info); } GUILayout.EndHorizontal(); for (int m = 0; m < inventoryElement.actions.Count; m++) { ElementAction itemAction = inventoryElement.actions[m]; if (itemAction != null) { GUILayout.BeginHorizontal(); GUILayout.Space(30); itemAction.foldout = EditorGUILayout.Foldout(itemAction.foldout, "Action " + m.ToString()); if (GUILayout.Button("x")) { inventoryElement.actions.RemoveAt(m); } GUILayout.EndHorizontal(); itemAction.OnGUI(); } } GUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button("Add Action")) { inventoryElement.actions.Add(new ElementAction()); } GUILayout.EndHorizontal(); } GUIStyle gs = new GUIStyle(); gs.alignment = TextAnchor.MiddleCenter; GUILayout.Space(10); editItem.deleteFoldout = EditorGUILayout.Foldout(editItem.deleteFoldout, "Delete"); if (editItem.deleteFoldout) { editItem.areYouSure = EditorGUILayout.Toggle("Are you sure?", editItem.areYouSure); if (editItem.areYouSure) { editItem.areYouSure2 = EditorGUILayout.Toggle("Are you REALLY sure?", editItem.areYouSure2); if (editItem.areYouSure2) { if (GUILayout.Button("Delete")) { GUI.FocusControl(null); editState = EditState.EMPTY; if (InventoryManager.Instance != null) { for (int i = 0; i < InventoryManager.Instance.allInventoryObjects.Count; i++) { for (int m = 0; m < InventoryManager.Instance.allInventoryObjects[i].Slots.Count; m++) { if (InventoryManager.Instance.allInventoryObjects[i].Slots[m].inventoryElement.id == editItem.id) { InventoryManager.Instance.allInventoryObjects[i].Slots[m].inventoryElement = new InventoryElement(); } } } } if (InventoryDatabase.Instance != null) { if (editItem.id != -1) { InventoryDatabase.Remove(editItem); } } } } } } } }
void EditItemType() { if (editType != null) { editType.name = EditorGUILayout.TextField("Name", editType.name); editType.tooltipColor = EditorGUILayout.ColorField("Tooltip Color", editType.tooltipColor); GUILayout.BeginHorizontal(); editType.windowActionFoldout = EditorGUILayout.Foldout(editType.windowActionFoldout, "Action Management"); GUILayout.EndHorizontal(); if (editType.windowActionFoldout) { GUILayout.BeginHorizontal(); GUILayout.Space(15); actionInfoFoldout = EditorGUILayout.Foldout(actionInfoFoldout, "Info"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(15); if (actionInfoFoldout) { EditorGUILayout.HelpBox("When you choose an Object for an action, make sure you choose an Object in the current scene" + " if you need to work with an instance of a script. Example: If you need to affect your character's health, then " + "select the object that has the Health script in the Scene as opposed to the Assets.", MessageType.Info); } GUILayout.EndHorizontal(); for (int m = 0; m < editType.actions.Count; m++) { ElementAction itemAction = editType.actions[m]; if (itemAction != null) { GUILayout.BeginHorizontal(); GUILayout.Space(30); itemAction.foldout = EditorGUILayout.Foldout(itemAction.foldout, "Action " + m.ToString()); if (GUILayout.Button("x", EditorStyles.miniButton)) { editType.actions.RemoveAt(m); } GUILayout.EndHorizontal(); itemAction.OnGUI(); } } GUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button("Add Action")) { editType.actions.Add(new ElementAction()); } GUILayout.EndHorizontal(); } GUILayout.Space(10); editType.deleteFoldout = EditorGUILayout.Foldout(editType.deleteFoldout, "Delete"); if (editType.deleteFoldout) { editType.areYouSure = EditorGUILayout.Toggle("Are you sure?", editType.areYouSure); if (editType.areYouSure) { editType.areYouSure2 = EditorGUILayout.Toggle("Are you REALLY sure?", editType.areYouSure2); if (editType.areYouSure2) { if (GUILayout.Button("Delete")) { GUI.FocusControl(null); editState = EditState.EMPTY; InventoryDatabase.Remove(editType); } } } } } }