4 using System.Collections.Generic;
18 private Dictionary<TSetting, bool> values =
new Dictionary<TSetting, bool>();
19 private Dictionary<TSetting, string> names =
new Dictionary<TSetting, string>();
20 private Dictionary<TSetting, string> descriptions =
new Dictionary<TSetting, string>();
22 private string statusMessage =
string.Empty;
23 private Vector2 scrollPosition = Vector2.zero;
24 private GUIStyle wrapStyle;
26 #endregion // Member Fields 28 #region Internal Methods 30 private void SettingToggle(TSetting setting)
32 EditorGUI.BeginChangeCheck();
35 values[setting] = GUILayout.Toggle(values[setting],
new GUIContent(names[setting]));
37 if (EditorGUI.EndChangeCheck())
43 if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
45 StatusMessage = descriptions[setting];
53 private string StatusMessage {
get {
return statusMessage; }
set { statusMessage = value; } }
58 private void SelectAll()
60 var keys = values.Keys.ToArray();
61 for (
int iKey = 0; iKey < keys.Length; iKey++)
63 Values[keys[iKey]] =
true;
70 private void SelectNone()
72 var keys = values.Keys.ToArray();
73 for (
int iKey = 0; iKey < keys.Length; iKey++)
75 Values[keys[iKey]] =
false;
79 #endregion // Internal Methods 81 #region Overridables / Event Triggers 86 protected abstract void ApplySettings();
91 protected abstract void LoadSettings();
96 protected abstract void LoadStrings();
101 protected abstract void OnGuiChanged();
103 #endregion // Overridables / Event Triggers 105 #region Overrides / Event Handlers 112 wrapStyle =
new GUIStyle(
"label")
131 GUILayout.BeginVertical(EditorStyles.helpBox);
134 var keys = values.Keys.ToArray();
135 for (
int iKey = 0; iKey < keys.Length; iKey++)
137 SettingToggle(keys[iKey]);
141 GUILayout.EndVertical();
144 GUILayout.BeginVertical(EditorStyles.helpBox);
145 scrollPosition = GUILayout.BeginScrollView(scrollPosition);
146 GUILayout.Label(statusMessage, wrapStyle);
147 GUILayout.EndScrollView();
148 GUILayout.EndVertical();
151 GUILayout.BeginHorizontal(EditorStyles.miniButtonRight);
152 bool selectAllClicked = GUILayout.Button(
"Select All");
153 bool selectNoneClicked = GUILayout.Button(
"Select None");
154 bool applyClicked = GUILayout.Button(
"Apply");
155 GUILayout.EndHorizontal();
158 if (selectAllClicked)
163 if (selectNoneClicked)
174 #endregion // Overrides / Event Handlers 176 #region Protected Properties 181 protected Dictionary<TSetting, string> Descriptions
190 descriptions = value;
197 protected Dictionary<TSetting, string> Names
213 protected Dictionary<TSetting, bool> Values
226 #endregion // Protected Properties