void OnGUI() { GUIStyle titleStyle = new GUIStyle("button"); titleStyle.alignment = TextAnchor.MiddleCenter; titleStyle.fontSize = 20; titleStyle.fontStyle = FontStyle.Bold; GUIStyle centeredStyle = new GUIStyle(); centeredStyle.alignment = TextAnchor.MiddleCenter; GUIStyle centeredMediumStyle = new GUIStyle(); centeredMediumStyle.alignment = TextAnchor.MiddleCenter; centeredMediumStyle.fontSize = 15; centeredMediumStyle.fontStyle = FontStyle.Bold; GUIStyle leftMiddleStyle = new GUIStyle(); leftMiddleStyle.alignment = TextAnchor.MiddleLeft; leftMiddleStyle.fontSize = 15; leftMiddleStyle.fontStyle = FontStyle.Bold; EditorGUILayout.BeginVertical(); { GUILayout.Label("Language " + CurrentLang, centeredMediumStyle); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical("box", GUILayout.Width(position.width * 0.9f - 20), GUILayout.ExpandHeight(true)); { GUILayout.Label("Traductions", centeredMediumStyle); _scrollPositionLanguages = EditorGUILayout.BeginScrollView(_scrollPositionLanguages); { if (CurrentLang == null) { GUILayout.Label("No Language Selected", centeredMediumStyle); } else if (_rootLines.Count > 0) { for (int i = 0; i < _rootLines.Count; ++i) { GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(_rootLines[i], EditorStyles.label, GUILayout.ExpandWidth(false)); string testFrag; if (!_languageLines.TryGetValue(_rootLines[i], out testFrag)) { _languageLines.Add(_rootLines[i], ""); } _languageLines[_rootLines[i]] = EditorGUILayout.TextField(_languageLines[_rootLines[i]], GUILayout.ExpandWidth(true)); } EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); } else { GUILayout.Label("No root label found", centeredMediumStyle); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box", GUILayout.Width(position.width * 0.1f), GUILayout.ExpandHeight(true), GUILayout.MinWidth(100)); { GUILayout.Label("Options", centeredMediumStyle); if (GUILayout.Button("Export")) { Export(CurrentLang); } if (GUILayout.Button("Update")) { Update(CurrentLang); LoadFiles(); } if (GUILayout.Button("Backup")) { Backup(CurrentLang); } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); if (CurrentLang != null) { GUI.color = Color.green; if (GUILayout.Button("Save File", titleStyle)) { CustomEditorWindow_Localizator.SaveLocalizationFile(CurrentLang, _languageLines); LoadFiles(); CustomEditorWindow_Localizator.SaveWorkspace(); } GUI.color = _defaultColor; } } EditorGUILayout.EndVertical(); }
void OnGUI() { GUIStyle titleStyle = new GUIStyle("button"); titleStyle.alignment = TextAnchor.MiddleCenter; titleStyle.fontSize = 20; titleStyle.fontStyle = FontStyle.Bold; GUIStyle centeredStyle = new GUIStyle(); centeredStyle.alignment = TextAnchor.MiddleCenter; GUIStyle centeredMediumStyle = new GUIStyle(); centeredMediumStyle.alignment = TextAnchor.MiddleCenter; centeredMediumStyle.fontSize = 15; centeredMediumStyle.fontStyle = FontStyle.Bold; GUIStyle leftMiddleStyle = new GUIStyle(); leftMiddleStyle.alignment = TextAnchor.MiddleLeft; leftMiddleStyle.fontSize = 15; leftMiddleStyle.fontStyle = FontStyle.Bold; List <string> labelsToRemove = new List <string>(); EditorGUILayout.BeginVertical(); { GUILayout.Label("Edit Root "); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical("box", GUILayout.Width(position.width * 0.5f - 5), GUILayout.ExpandHeight(true)); { GUILayout.Label("Root Labels", centeredMediumStyle); _scrollPositionRootLabels = EditorGUILayout.BeginScrollView(_scrollPositionRootLabels, "box"); { if (_rootLines.Count > 0) { for (int i = 0; i < _rootLines.Count; ++i) { GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(50)); _rootLines[i] = EditorGUILayout.TextField(_rootLines[i], GUILayout.ExpandWidth(true)); GUI.color = Color.red; if (GUILayout.Button("-", GUILayout.Width(50))) { labelsToRemove.Add(_rootLines[i]); } GUI.color = _defaultColor; } EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); } else { GUILayout.Label("No root label found", centeredMediumStyle); } } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Add Root Label")) { _rootLines.Add(""); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box", GUILayout.Width(position.width * 0.5f - 5), GUILayout.ExpandHeight(true)); { GUILayout.Label("Options", centeredMediumStyle); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); for (int i = 0; i < labelsToRemove.Count; ++i) { _rootLines.Remove(labelsToRemove[i]); } GUI.color = Color.green; if (GUILayout.Button("Save File", titleStyle)) { CustomEditorWindow_Localizator.SaveRootFile(_rootLines); LoadRootFile(); CustomEditorWindow_Localizator.SaveWorkspace(); } GUI.color = _defaultColor; } EditorGUILayout.EndVertical(); }