4 using UnityEditorInternal;
14 public class SettingsWindow : EditorWindow
20 [InitializeOnLoadMethod]
21 private static void OpenWindowAtFirstUse()
24 if (!InternalEditorUtility.isHumanControllingUs || InternalEditorUtility.inBatchMode)
27 if (!SavedData.settingsShown)
29 EditorApplication.delayCall += () =>
32 SavedData.settingsShown =
true;
41 [MenuItem(
"Window/Essentials/Settings")]
42 private static void OpenWindow()
45 SettingsWindow window = CreateWindow<SettingsWindow>();
47 Vector2 windowSize =
new Vector2(600f, 420f);
48 window.minSize = window.maxSize = windowSize;
49 window.position = Utils.GetEditorWindowCenteredPosition(windowSize);
50 window.titleContent =
new GUIContent(
"Essentials' Settings and Adjustments");
58 private Type[] adjustments;
65 if (adjustments ==
null || adjustments.Length == 0)
68 GUILayout.Label(
"Essentials Settings", EditorStyles.boldLabel);
71 if (adjustments !=
null && adjustments.Length != 0)
74 GUILayout.Label(
"Available adjustments:");
76 EditorGUILayout.BeginHorizontal();
78 EditorGUILayout.BeginVertical();
79 foreach (Type adjustmentType
in adjustments)
81 IAdjustment adjustment = (IAdjustment) Activator.CreateInstance(adjustmentType);
82 if (!adjustment.showInSettingsWindow)
84 GUILayout.Label($
" • {adjustment.title}");
86 EditorGUILayout.EndVertical();
88 EditorGUILayout.BeginVertical();
89 foreach (Type adjustmentType
in adjustments)
92 IAdjustment adjustment = (IAdjustment) Activator.CreateInstance(adjustmentType);
93 if (!adjustment.showInSettingsWindow)
96 EditorGUILayout.BeginHorizontal();
98 if (GUILayout.Button(
new GUIContent(adjustment.infoButtonText, $
"Open {adjustment.infoURL}")))
99 adjustment.OpenInfoURL();
103 if (GUILayout.Button(
new GUIContent(adjustment.applyButtonText, adjustment.applyAdjustmentShortExplanation)))
105 if (GUILayout.Button(
new GUIContent(adjustment.revertButtonText, adjustment.revertAdjustmentShortExplanation)))
108 EditorGUILayout.EndHorizontal();
110 EditorGUILayout.EndVertical();
112 EditorGUILayout.EndHorizontal();
117 EditorGUILayout.BeginHorizontal();
118 if (GUILayout.Button(
"Apply all"))
120 foreach (Type adjustmentType
in adjustments)
122 IAdjustment adjustment = (IAdjustment) Activator.CreateInstance(adjustmentType);
127 if (GUILayout.Button(
"Revert all"))
129 foreach (Type adjustmentType
in adjustments)
131 IAdjustment adjustment = (IAdjustment) Activator.CreateInstance(adjustmentType);
135 EditorGUILayout.EndHorizontal();
144 GUIStyle style = GUI.skin.label;
145 TextAnchor defaultAlignment = style.alignment;
146 style.alignment = TextAnchor.MiddleRight;
147 GUILayout.Label (GUI.tooltip, style);
148 style.alignment = defaultAlignment;
161 EditorGUILayout.LabelField(
"", GUI.skin.horizontalSlider);
165 EditorGUILayout.BeginHorizontal();
166 if (GUILayout.Button(
new GUIContent(
"Rate the asset! ❤️",
"Open the Asset Store page of the asset, so you can rate it, share it or give any kind of love you want!" )))
167 EssentialsHelp.OpenLinkRateAsset();
168 if (GUILayout.Button(
new GUIContent(
"Give feedback or any ideas! 💡",
"Open a form to share any thoughts you have about the asset, so we can keep improving." )))
169 EssentialsHelp.OpenLinkFeedback();
170 if (GUILayout.Button(
new GUIContent(
"About me : )",
"Open my personal webpage where you can know more about me!" )))
171 EssentialsHelp.OpenLinkAboutMe();
172 EditorGUILayout.EndHorizontal();
173 EditorGUILayout.BeginHorizontal();
174 if (GUILayout.Button(
new GUIContent(
"Quick Documentation",
"Open the online document containing the quick documentation of the latest version of the asset." )))
175 EssentialsHelp.OpenLinkDocumentation();
176 if (GUILayout.Button(
new GUIContent(
"Scripting Documentation",
"Open the online scripting documentation of the latest version of the asset." )))
177 EssentialsHelp.OpenLinkScriptingDocumentation();
178 if (GUILayout.Button(
new GUIContent(
"GitHub",
"Open the GitHub repository of the asset. You are welcome to collaborate!" )))
179 EssentialsHelp.OpenLinkGitHubRepository();
180 EditorGUILayout.EndHorizontal();
187 private void SearchAdjustments()
189 adjustments = Utils.GetTypeImplementationsNotUnityObject<IAdjustment>();