LabelUtilityWindow.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.Strings = new List<string>();
  53. eventString.Strings.Add("On#NEWNAMEClick");
  54. Instance.EventStrings.Add(eventString);
  55. }
  56. EditorGUILayout.PropertyField(DllNames, new GUIContent("DllNames"), true);
  57. EditorGUILayout.PropertyField(EventStrings, new GUIContent("EventStrings"), true);
  58. EditorGUILayout.PropertyField(LabelSets, new GUIContent("LabelSets"), true);
  59. EditorGUILayout.EndScrollView();
  60. SerializedObject.ApplyModifiedProperties();
  61. }
  62. }
  63. }