123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- namespace labelUtility
- {
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- using UnityEditor;
- using UnityEngine;
- public class LabelUtilityWindow : EditorWindow
- {
- #region Config
- protected Vector2 ScrollPosition;
- protected LabelUtility Instance;
- protected SerializedProperty LabelSets;
- protected SerializedProperty DllNames;
- protected SerializedProperty EventStrings;
-
- protected SerializedObject SerializedObject;
- #endregion
- [MenuItem("DashGame/LabelUtility")]
- protected static void ShowWindow()
- {
- Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
- LabelUtilityWindow window = GetWindow<LabelUtilityWindow>(inspectorType);
- window.titleContent = new GUIContent("LabelUtility");
- window.Show();
- }
- private void OnEnable()
- {
- Instance = InstanceManager.SearchInstance<LabelUtility>();
- SerializedObject = new SerializedObject(Instance);
- LabelSets = SerializedObject.FindProperty("LabelSets");
- DllNames = SerializedObject.FindProperty("DllNames");
- EventStrings = SerializedObject.FindProperty("EventStrings");
-
- }
- private void OnGUI()
- {
- SerializedObject.Update();
- ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition);
- if (!Instance.DllNames.Valid())
- {
- Instance.DllNames = new List<string>();
- Instance.DllNames.Add("UnityEngine");
- Instance.DllNames.Add("UnityEngine.UI");
- }
- if (!Instance.EventStrings.Valid())
- {
- Instance.EventStrings = new List<ComponentEventString>();
- ComponentEventString eventString = new ComponentEventString();
- eventString.ComponentType = ComponentType.Button;
- eventString.RegistStrings = new List<string>();
- eventString.RegistStrings.Add("#NEWNAME.onClick.AddListener(On#NEWNAMEClick)");
- eventString.MethodNames = new List<string>();
- eventString.MethodNames.Add("void On#NEWNAMEClick()");
- Instance.EventStrings.Add(eventString);
- eventString = new ComponentEventString();
- eventString.ComponentType = ComponentType.Text;
- eventString.RegistStrings = new List<string>();
- eventString.RegistStrings.Add("LanguageManager.Add(#NEWNAME, new MulLanStr(LanguageLabel.#NAME))");
- eventString.MethodNames = new List<string>();
- eventString.MethodNames.Add("On#NEWNAMEClick");
- Instance.EventStrings.Add(eventString);
- eventString = new ComponentEventString();
- eventString.ComponentType = ComponentType.VirtualScrollRectPlus;
- eventString.RegistStrings = new List<string>();
- eventString.RegistStrings.Add("#NAME.OnSaveItem += OnSave#NAMEItem");
- eventString.RegistStrings.Add("#NAME.OnGetNextItem += OnGetNext#NAMEItem");
- eventString.RegistStrings.Add("#NAME.OnGetPreviousItem += OnGetPrevious#NAMEItem");
- eventString.MethodNames = new List<string>();
- eventString.MethodNames.Add("void OnSave#NAMEItem(int index, VirtualScrollRectItem item)");
- eventString.MethodNames.Add("VirtualScrollRectItem OnGetNext#NAMEItem(int index)");
- eventString.MethodNames.Add("VirtualScrollRectItem OnGetPrevious#NAMEItem(int index)");
- Instance.EventStrings.Add(eventString);
- }
- EditorGUILayout.PropertyField(DllNames, new GUIContent("DllNames"), true);
- EditorGUILayout.PropertyField(EventStrings, new GUIContent("EventStrings"), true);
- EditorGUILayout.PropertyField(LabelSets, new GUIContent("LabelSets"), true);
- EditorGUILayout.EndScrollView();
- SerializedObject.ApplyModifiedProperties();
- }
- }
- }
|