/// <summary> /// Reset the settings to the default state. /// </summary> public void ResetDefaults() { if (instance == null) { return; } _instance = null; #if UNITY_EDITOR AssetDatabase.DeleteAsset(ProjectPath + "Resources/" + fileName + ".asset"); AssetDatabase.SaveAssets(); #endif }
void OnGUI() { if (invisibleButtonStyle == null) { invisibleButtonStyle = new GUIStyle("Button"); invisibleButtonStyle.normal.background = null; invisibleButtonStyle.focused.background = null; invisibleButtonStyle.hover.background = null; invisibleButtonStyle.active.background = null; } if (boxStyle == null) { boxStyle = new GUIStyle("Box"); boxStyle.normal.textColor = invisibleButtonStyle.normal.textColor; boxStyle.focused.textColor = invisibleButtonStyle.focused.textColor; boxStyle.hover.textColor = invisibleButtonStyle.hover.textColor; boxStyle.active.textColor = invisibleButtonStyle.active.textColor; boxStyle.fontStyle = FontStyle.Bold; } GUILayout.BeginVertical("uNature " + UNSettings.ProjectVersion, boxStyle); GUILayout.Space(15); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); UNSettingCategory category; object drawValue; for (int i = 0; i < UNSettingCategory.categories.Count; i++) { EditorGUILayout.BeginVertical(boxStyle); category = UNSettingCategory.categories[i]; category.show = EditorGUILayout.Foldout(category.show, "Show " + category.type.ToString() + " Settings"); if (category.show) { GUILayout.Space(15); for (int b = 0; b < category.attributes.Count; b++) { drawValue = category.attributes[b].Draw(category.fields[b].GetValue(settings)); if (drawValue != null) { category.fields[b].SetValue(settings, drawValue); } } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Reset To Default")) { settings.ResetDefaults(); _settings = null; GUILayout.EndVertical(); return; } if (GUILayout.Button("Save")) { EditorUtility.SetDirty(settings); AssetDatabase.SaveAssets(); } GUILayout.EndVertical(); }