private static void RefreshDefineState(bool force = false) { if (force || (_defines == null) || (_reorderableDefines == null)) { _defines = new List <string>(ScriptingDefineManager.GetDefines()); _reorderableDefines = new ReorderableList(_defines, typeof(string), true, true, true, true) { headerHeight = 1, drawElementCallback = (rect, index, isActive, isFocused) => DrawTextField(rect, index), onAddCallback = list => { _defines.Add(""); _definesHaveChanged = true; }, onRemoveCallback = list => { _defines.RemoveAt(list.index); _definesHaveChanged = true; } }; _reorderableDefines.onChangedCallback += list => _definesHaveChanged = true; } }
private static void DrawButtons() { var enabled = GUI.enabled; GUI.enabled = true; if (GUILayout.Button("Manual Update", EditorStyles.miniButton)) { ScriptingDefineManager.Execute(); RefreshDefineState(); } EditorGUILayout.Space(); if (GUILayout.Button("Sort", EditorStyles.miniButton)) { _defines.Sort(); ScriptingDefineManager.SaveNewDefines(_defines); RefreshDefineState(); } if (GUILayout.Button("Sort (Desc)", EditorStyles.miniButton)) { _defines.Sort(); _defines.Reverse(); ScriptingDefineManager.SaveNewDefines(_defines); RefreshDefineState(); } EditorGUILayout.Space(); if (GUILayout.Button("Clear", EditorStyles.miniButton)) { ScriptingDefineManager.ResetDefines(); RefreshDefineState(); } GUI.enabled = !string.IsNullOrWhiteSpace(ScriptingDefineSettings.BackupDefines); if (GUILayout.Button("Restore", EditorStyles.miniButton)) { ScriptingDefineManager.RestoreDefines(); RefreshDefineState(); } EditorGUILayout.Space(); GUI.enabled = true; if (GUILayout.Button("Copy", EditorStyles.miniButton)) { EditorGUIUtility.systemCopyBuffer = ScriptingDefineManager.GetDefinesUnformatted(); } GUI.enabled = _definesHaveChanged; if (GUILayout.Button("Revert", EditorStyles.miniButton)) { RefreshDefineState(); } if (GUILayout.Button("Apply", EditorStyles.miniButton)) { ScriptingDefineManager.SaveNewDefines(_defines); RefreshDefineState(); } GUI.enabled = enabled; }