public override void OnInspectorGUI() { mainScript = (InventoryManager)target; GUI.color = Color.yellow; EditorGUILayout.LabelField("Settings"); GUI.color = Color.white; mainScript.alphaReworkUI = EditorGUILayout.Toggle(new GUIContent("Alpha UI Rework", REWORK_UI_TOOLTIP), mainScript.alphaReworkUI); if (!mainScript.alphaReworkUI) { GUI.color = Color.yellow; EditorGUILayout.LabelField(MANUAL_REWORK_TOOLTIP, EditorStyles.wordWrappedLabel); return; } mainScript.settings.cellNumber = EditorGUILayout.IntSlider(new GUIContent("Cell amount", CELL_AMOUNT_TOOLTIP), mainScript.settings.cellNumber, MAX_MIN_CELL_AMOUNT[0], MAX_MIN_CELL_AMOUNT[1]); EditorGUILayout.Space(5); DisplaySizes(); //NEED TO WORK ON THIS IT"S NOT WORKING PROPERLY //mainScript.onValueChange = EditorGUILayout.Toggle(new GUIContent("Update editor", UPDATE_EDITOR_TOOLTIP), mainScript.onValueChange); mainScript.settings.addEventSystem = EditorGUILayout.Toggle(new GUIContent("Add Event System", ADD_EVENTSYSTEM_STRING), mainScript.settings.addEventSystem); mainScript.settings.destroyOnThrow = EditorGUILayout.Toggle(new GUIContent("Destroy on throw", DESTROY_ONTHROW_TOOLTIP), mainScript.settings.destroyOnThrow); if (mainScript.onValueChange && mainScript.settings != localSettings) { UICreator.CreatePreview(ref mainScript.settings, mainScript.transform); localSettings = mainScript.settings; } mainScript.settings.bgColor = EditorGUILayout.ColorField(new GUIContent("BG color", BG_COLOR_TOOLTIP), mainScript.settings.bgColor); mainScript.settings.slotBgColor = EditorGUILayout.ColorField(new GUIContent("Slot BG color", SLOT_BG_COLOR_TOOLTIP), mainScript.settings.slotBgColor); mainScript.settings.stackSlotTextColor = EditorGUILayout.ColorField(new GUIContent("Stack text color", STACK_SLOT_TEXT_COLOR), mainScript.settings.stackSlotTextColor); EditorGUILayout.Space(10); mainScript.settings.uiOpenInput = (KeyCode)EditorGUILayout.EnumPopup(new GUIContent("UI Input", UI_INPUT_STRING), mainScript.settings.uiOpenInput); EditorGUILayout.Space(10); DisplaySprites(); DisplayPadding(); DisplayButtons(); }
private void DisplayButtons() { EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add random item", GUILayout.MinHeight(25))) { DynamicData[] folderItems = Resources.LoadAll(GENERATED_ITEMS_FOLDER).Cast <DynamicData>().ToArray(); int emptyIndex = UICreator.cells.FindIndex(x => { return(x.cellData.isEmpty); }); if (emptyIndex > -1) { int randomItem = Random.Range(0, folderItems.Length); UICreator.cells[emptyIndex].cellData.AssignItem(folderItems[randomItem], 1); } else { Debug.LogError("No more empty cells!"); } } GUI.backgroundColor = Color.red; if (GUILayout.Button("Clear items", GUILayout.MinHeight(25))) { foreach (var cell in UICreator.cells) { cell.cellData.ClearCell(); } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.yellow; GUILayout.Space(5f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create UI Preview", GUILayout.MinHeight(25))) { UICreator.CreatePreview(ref mainScript.settings, mainScript.transform); PrefabUtility.RecordPrefabInstancePropertyModifications(UICreator.inventoryCanvas); } GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete UI Preview", GUILayout.MinHeight(25))) { if (UICreator.inventoryCanvas == null) { Debug.LogWarning("Nothing to delete"); return; } DestroyImmediate(UICreator.inventoryCanvas); } GUI.backgroundColor = Color.blue; if (GUILayout.Button("Reset Layout", GUILayout.MinHeight(25))) { mainScript.settings.ResetSettings(); } GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Create Prefab", GUILayout.MinHeight(25))) { CreatePrefab(); } GUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; }