using TyphoonGUIStyle; using UnityEditor; using UnityEngine; namespace TyphoonUI { [CustomEditor(typeof(ViewNamespace))] public class ViewNamespaceEditor : Editor { ViewNamespace Target => target as ViewNamespace; private Vector2 _scroll; public override void OnInspectorGUI() { _scroll = GUILayout.BeginScrollView(_scroll); var last = GUIDrawer.DrawTitleLabel("命名空间列表", GUILayout.Height(32)); var rectSave = last; rectSave.width = 80; rectSave.height = 22; rectSave.center = last.center; rectSave.x = last.xMax - rectSave.width - 4; var clickSave = GUI.Button(rectSave, new GUIContent("保存配置", EditorIcons.icon_save)); var clickRemove = false; var removeIndex = -1; for (int i = 0; i < Target.Namespaces.Count; i++) { GUILayout.BeginHorizontal(); Target.Namespaces[i] = EditorGUILayout.TextField(Target.Namespaces[i], GUILayout.Height(24)); if (GUILayout.Button("-", Styles.Btn, GUILayout.Width(44), GUILayout.Height(24))) { clickRemove = true; removeIndex = i; } GUILayout.EndHorizontal(); } GUILayout.Space(3); GUILayout.BeginHorizontal(); var clickAdd = false; clickAdd = GUILayout.Button("+", Styles.Btn, GUILayout.Width(44)); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); if (clickRemove) { Target.Namespaces.RemoveAt(removeIndex); clickRemove = false; } if (clickAdd) { Target.Namespaces.Add(""); clickAdd = false; } if (clickSave) { Target.Save(); clickSave = false; } Repaint(); } } }