LabelUtilityLabelUtilityWindow.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text.RegularExpressions;
  7. using AtlasUtility;
  8. using UnityEditor;
  9. using UnityEngine;
  10. public class LabelUtilityWindow : EditorWindow
  11. {
  12. #region Config
  13. protected LabelUtility Instance;
  14. protected SerializedProperty Script;
  15. protected SerializedProperty Languages;
  16. protected SerializedProperty Prefabs;
  17. protected SerializedObject SerializedObject;
  18. #endregion
  19. [MenuItem("DashGame/LabelUtility")]
  20. protected static void ShowWindow()
  21. {
  22. Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
  23. LabelUtilityWindow window = GetWindow<LabelUtilityWindow>(inspectorType);
  24. window.titleContent = new GUIContent("LabelUtility");
  25. window.Show();
  26. }
  27. private void OnEnable()
  28. {
  29. Instance = InstanceManager.SearchInstance<LabelUtility>();
  30. SerializedObject = new SerializedObject(Instance);
  31. Script = SerializedObject.FindProperty("Script");
  32. Languages = SerializedObject.FindProperty("Languages");
  33. Prefabs = SerializedObject.FindProperty("Prefabs");
  34. }
  35. private void OnGUI()
  36. {
  37. SerializedObject.Update();
  38. EditorGUILayout.PropertyField(Script, new GUIContent("Script"));
  39. EditorGUILayout.PropertyField(Prefabs, new GUIContent("Prefabs"), true);
  40. EditorGUILayout.PropertyField(Languages, new GUIContent("Languages"), true);
  41. if (GUILayout.Button("ClearLabels"))
  42. {
  43. Instance.ClearLabels();
  44. }
  45. if (GUILayout.Button("CreateLabelFromPrefabs"))
  46. {
  47. Instance.CreateLabelFromPrefabs();
  48. }
  49. if (GUILayout.Button("CreateLabelFromLanguage"))
  50. {
  51. Instance.CreateLabelFromLanguage();
  52. }
  53. //if (GUILayout.Button("ReplaceLanguageLabels"))
  54. //{
  55. // Instance.ReplaceLanguageLabels();
  56. //}
  57. SerializedObject.ApplyModifiedProperties();
  58. }
  59. }