using UnityEditor; using UnityEngine; namespace XRTool.Util { [InitializeOnLoad] [CustomEditor(typeof(MultTextHelper))] public class MultTextHelperEditor : Editor { private SerializedProperty isClearOnNothing; //private SerializedProperty languageNum; private MultTextHelper textHelper; //private SerializedProperty languageIndex; private int num; private int minNum, maxNum; private void OnEnable() { isClearOnNothing = serializedObject.FindProperty("isClearOnNothing"); //languageIndex = serializedObject.FindProperty("languageIndex"); textHelper = target as MultTextHelper; textHelper.languageIndex = SystemSettingMgr.Instance.settings.Language; textHelper.AutoGetComponent(); int.TryParse(textHelper.languageNum, out num); if (LanguageMgr.Instance.CurLanguage != null) { minNum = LanguageMgr.Instance.CurLanguage.GetMin(); maxNum = LanguageMgr.Instance.CurLanguage.GetMax(); } } public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.PropertyField(isClearOnNothing, new GUIContent("无编号时清除")); //EditorGUILayout.PropertyField(languageIndex, new GUIContent("中英文")); num = (int)EditorGUILayout.Slider("文字编号", num, minNum-1, maxNum); textHelper.languageIndex = (int)EditorGUILayout.Slider("语言", textHelper.languageIndex, 0, LanguageMgr.Instance.LanguageCount); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { if (textHelper.languageNum != num.ToString()) { textHelper.languageNum = num.ToString(); if (textHelper) { textHelper.SetLanuageNum(textHelper.languageNum); } } if (textHelper.languageIndex != SystemSettingMgr.Instance.settings.Language) { LanguageMgr.Instance.SelectLanguage(textHelper.languageIndex); } } } } }