LabelUtilityWindow.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. namespace labelUtility
  2. {
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text.RegularExpressions;
  9. using UnityEditor;
  10. using UnityEngine;
  11. public class LabelUtilityWindow : EditorWindow
  12. {
  13. #region Config
  14. protected Vector2 ScrollPosition;
  15. protected LabelUtility Instance;
  16. protected SerializedProperty LabelSets;
  17. protected SerializedProperty DllNames;
  18. protected SerializedProperty EventStrings;
  19. protected SerializedObject SerializedObject;
  20. #endregion
  21. [MenuItem("DashGame/LabelUtility")]
  22. protected static void ShowWindow()
  23. {
  24. Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
  25. LabelUtilityWindow window = GetWindow<LabelUtilityWindow>(inspectorType);
  26. window.titleContent = new GUIContent("LabelUtility");
  27. window.Show();
  28. }
  29. private void OnEnable()
  30. {
  31. Instance = InstanceManager.SearchInstance<LabelUtility>();
  32. SerializedObject = new SerializedObject(Instance);
  33. LabelSets = SerializedObject.FindProperty("LabelSets");
  34. DllNames = SerializedObject.FindProperty("DllNames");
  35. EventStrings = SerializedObject.FindProperty("EventStrings");
  36. }
  37. private void OnGUI()
  38. {
  39. SerializedObject.Update();
  40. ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition);
  41. if (!Instance.DllNames.Valid())
  42. {
  43. Instance.DllNames = new List<string>();
  44. Instance.DllNames.Add("UnityEngine");
  45. Instance.DllNames.Add("UnityEngine.UI");
  46. }
  47. if (!Instance.EventStrings.Valid())
  48. {
  49. Instance.EventStrings = new List<ComponentEventString>();
  50. ComponentEventString eventString = new ComponentEventString();
  51. eventString.ComponentType = ComponentType.Button;
  52. eventString.RegistStrings = new List<string>();
  53. eventString.RegistStrings.Add("#NEWNAME.onClick.AddListener(On#NEWNAMEClick)");
  54. eventString.MethodNames = new List<string>();
  55. eventString.MethodNames.Add("void On#NEWNAMEClick()");
  56. Instance.EventStrings.Add(eventString);
  57. eventString = new ComponentEventString();
  58. eventString.ComponentType = ComponentType.Text;
  59. eventString.RegistStrings = new List<string>();
  60. eventString.RegistStrings.Add("LanguageManager.Add(#NEWNAME, new MulLanStr(LanguageLabel.#NAME))");
  61. eventString.MethodNames = new List<string>();
  62. eventString.MethodNames.Add("On#NEWNAMEClick");
  63. Instance.EventStrings.Add(eventString);
  64. eventString = new ComponentEventString();
  65. eventString.ComponentType = ComponentType.VirtualScrollRectPlus;
  66. eventString.RegistStrings = new List<string>();
  67. eventString.RegistStrings.Add("#NAME.OnSaveItem += OnSave#NAMEItem");
  68. eventString.RegistStrings.Add("#NAME.OnGetNextItem += OnGetNext#NAMEItem");
  69. eventString.RegistStrings.Add("#NAME.OnGetPreviousItem += OnGetPrevious#NAMEItem");
  70. eventString.MethodNames = new List<string>();
  71. eventString.MethodNames.Add("void OnSave#NAMEItem(int index, VirtualScrollRectItem item)");
  72. eventString.MethodNames.Add("VirtualScrollRectItem OnGetNext#NAMEItem(int index)");
  73. eventString.MethodNames.Add("VirtualScrollRectItem OnGetPrevious#NAMEItem(int index)");
  74. Instance.EventStrings.Add(eventString);
  75. }
  76. EditorGUILayout.PropertyField(DllNames, new GUIContent("DllNames"), true);
  77. EditorGUILayout.PropertyField(EventStrings, new GUIContent("EventStrings"), true);
  78. EditorGUILayout.PropertyField(LabelSets, new GUIContent("LabelSets"), true);
  79. EditorGUILayout.EndScrollView();
  80. SerializedObject.ApplyModifiedProperties();
  81. }
  82. }
  83. }