LabelUtilityWindow.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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("On#NEWNAMEClick");
  56. Instance.EventStrings.Add(eventString);
  57. }
  58. EditorGUILayout.PropertyField(DllNames, new GUIContent("DllNames"), true);
  59. EditorGUILayout.PropertyField(EventStrings, new GUIContent("EventStrings"), true);
  60. EditorGUILayout.PropertyField(LabelSets, new GUIContent("LabelSets"), true);
  61. EditorGUILayout.EndScrollView();
  62. SerializedObject.ApplyModifiedProperties();
  63. }
  64. }
  65. }