10[CanEditMultipleObjects]
11public class Localization_SOURCE_Editor : Editor
13 private SerializedProperty LanguageFiles, SelectedLanguage;
14 private SerializedProperty LoadLanguageOnStart;
16 private SerializedProperty LocalizationSelector;
18 private SerializedProperty AT_GameObjectChildsRoot;
19 private SerializedProperty ExtraCanvas1;
20 private SerializedProperty ExtraCanvas2;
21 private SerializedProperty ExtraCanvas3;
23 private bool DrawList;
25 private SerializedProperty quickActions;
29 private bool categorySelected;
32 private string[] categories;
34 private void OnEnable()
38 LanguageFiles = serializedObject.FindProperty(
"LanguageFiles");
39 SelectedLanguage = serializedObject.FindProperty(
"SelectedLanguage");
40 LoadLanguageOnStart = serializedObject.FindProperty(
"LoadLanguageOnStart");
41 LocalizationSelector = serializedObject.FindProperty(
"LocalizationSelector");
42 AT_GameObjectChildsRoot = serializedObject.FindProperty(
"AT_GameObjectChildsRoot");
43 ExtraCanvas1 = serializedObject.FindProperty(
"ExtraCanvas1");
44 ExtraCanvas2 = serializedObject.FindProperty(
"ExtraCanvas2");
45 ExtraCanvas3 = serializedObject.FindProperty(
"ExtraCanvas3");
46 quickActions = serializedObject.FindProperty(
"quickActions");
48 categories =
new string[l.
Categories.Count + 1];
49 categories[0] =
"All";
54 public override void OnInspectorGUI()
56 if (target ==
null)
return;
57 serializedObject.Update();
62 pP(LanguageFiles,
"Language Files",
"",
true);
63 pP(SelectedLanguage,
"Selected Language",
"Currently selected language for the localization");
65 pP(LoadLanguageOnStart,
"Load Language On Start",
"Load localization after program startup");
73 Localization_SOURCE_Window.Init();
75 l.Internal_RefreshInternalLocalization();
81 if (pb(
"X", GUILayout.Width(40)))
84 categorySelected =
false;
89 ple(
"From Category:");
94 categorySelected =
true;
100 if (categorySelected)
103 if (pb(
"Add All", GUILayout.Width(120)))
105 for (var i = 0; i < Localization_SOURCE_Window.localizationElements.Count; i++)
107 if (Localization_SOURCE_Window.localizationElements[i].Category != category)
109 l.Internal_AddKey(Localization_SOURCE_Window.localizationElements[i].Key);
113 categorySelected =
false;
118 EditorGUILayout.BeginVertical(
"Box");
119 for (var i = 0; i < Localization_SOURCE_Window.localizationElements.Count; i++)
121 if (Localization_SOURCE_Window.localizationElements[i].Category != category)
125 if (sel.Key == Localization_SOURCE_Window.localizationElements[i].Key)
133 if (pb(Localization_SOURCE_Window.localizationElements[i].Key))
135 l.Internal_AddKey(Localization_SOURCE_Window.localizationElements[i].Key);
137 categorySelected =
false;
143 EditorGUILayout.EndVertical();
156 pP(quickActions,
"Quick Actions",
"Edit keys with quick actions",
true);
157 if (serializedObject.FindProperty(
"quickActions").isExpanded)
158 if (pb($
"Apply To All Keys in '{categories[l.selectedCategory]}' Category"))
168 sel.AT_TextMeshbject =
null;
169 sel.AT_UITextObject =
null;
170 sel.AT_UIObjects =
null;
183 pP(AT_GameObjectChildsRoot,
"GameObject Childs Root",
184 "Starting root for keys containing 'GameObjectChild' assignation type");
185 pP(ExtraCanvas1,
"Extra Root 1",
"Starting root for keys containing 'AutoFindText' assignation type");
186 pP(ExtraCanvas2,
"Extra Root 2",
"Starting root for keys containing 'AutoFindText' assignation type");
187 pP(ExtraCanvas3,
"Extra Root 3",
"Starting root for keys containing 'AutoFindText' assignation type");
188 GUILayout.Toggle(DrawList,
"Draw List");
194 private void pDrawList()
201 var item = LocalizationSelector.GetArrayElementAtIndex(i);
202 GUILayout.BeginHorizontal();
205 if (pb(
"X", GUILayout.Width(40)))
211 GUILayout.EndHorizontal();
212 if (!item.isExpanded)
222 EditorGUI.indentLevel += 1;
223 GUILayout.BeginHorizontal(
"Box");
224 ple(
"Key: " + sec.Key,
true);
225 pl(
"Category: " + l.
Categories[sec.Category]);
226 GUILayout.EndHorizontal();
230 pP(item.FindPropertyRelative(
"AssignationType"),
"Assignation Type");
232 switch (sec.AssignationType)
236 pP(item.FindPropertyRelative(
"AT_FindChildByKeyName"),
"Find Child By Key Name",
237 "If enabled, the system will find the child of the selected component type [below] by the key name");
238 if (!sec.AT_FindChildByKeyName)
239 pP(item.FindPropertyRelative(
"AT_ChildName"),
"Child Name");
241 EditorGUILayout.HelpBox(
"Object with name '" + sec.Key +
"' should exist", MessageType.None);
246 pP(item.FindPropertyRelative(
"AT_UseGeneralChildsRootObject"),
"Use General Childs Root Object");
247 if (!sec.AT_UseGeneralChildsRootObject)
248 pP(item.FindPropertyRelative(
"AT_CustomChildsRootObject"),
"Custom Childs Root Object");
254 pP(item.FindPropertyRelative(
"AT_UITextComponentAllowed"),
"UIText Component Allowed",
255 "If disabled, objects with UI Text component will be ignored");
256 pP(item.FindPropertyRelative(
"AT_TextMeshComponentAllowed"),
"TextMesh Component Allowed",
257 "If disabled, objects with Text Mesh component will be ignored");
263 EditorGUILayout.HelpBox(
264 "Object with Localization_KEY component should have an ID '" + sec.Key +
"'", MessageType.None);
269 pP(item.FindPropertyRelative(
"AT_UITextComponentAllowed"),
"UIText Component Allowed",
270 "If disabled, objects with UI Text component will be ignored");
271 pP(item.FindPropertyRelative(
"AT_TextMeshComponentAllowed"),
"TextMesh Component Allowed",
272 "If disabled, objects with Text Mesh component will be ignored");
277 pP(item.FindPropertyRelative(
"AT_UITextObject"),
"Specific UI Text",
278 "Assign specific UI Text objects",
true);
282 pP(item.FindPropertyRelative(
"AT_UIObjects"),
"Text Replacer",
"Assign specific UI objects",
true);
286 pP(item.FindPropertyRelative(
"AT_TextMeshbject"),
"Specific Text Mesh",
287 "Assign specific Text Mesh objects",
true);
292 EditorGUI.indentLevel -= 1;
297 #region LayoutShortcuts
299 private void pl(
string text)
301 GUILayout.Label(text);
304 private void ple(
string text,
bool bold =
false)
309 add += text +
"</b>";
313 var style =
new GUIStyle();
314 style.richText =
true;
315 style.normal.textColor =
Color.white;
316 EditorGUILayout.LabelField(text, style);
319 private void ps(
float space = 10)
321 GUILayout.Space(space);
324 private void pP(SerializedProperty p,
string Text,
string ToolTip =
"",
bool includeChilds =
false)
326 EditorGUILayout.PropertyField(p,
new GUIContent(Text, ToolTip), includeChilds);
327 serializedObject.ApplyModifiedProperties();
332 GUILayout.BeginVertical(
"Box");
337 GUILayout.EndVertical();
340 private bool pb(
string mess, GUILayoutOption opt =
null)
342 if (opt ==
null)
return GUILayout.Button(mess);
343 return GUILayout.Button(mess, opt);
bool AT_UseGeneralChildsRootObject
TextMesh[] SpecificTextMeshes
bool ClearAllPreviousTargets
bool useGeneralChildsRoot
_LocalizationSelector._AssignationType assignationType
List< string > Categories
List< _LocalizationSelector > LocalizationSelector
QuickActions quickActions