public override void OnInspectorGUI() { //base.OnInspectorGUI(); AniFxMgr aniFxMgr = target as AniFxMgr; Animation ani = aniFxMgr.GetComponent <Animation>(); if (ani == null) { EditorGUILayout.LabelField("找不到Animation,不能添加动作绑定的特效"); return; } string[] aniNames = ani.GetNames(); if (aniNames == null || aniNames.Length == 0) { EditorGUILayout.LabelField("Animation没有动作"); return; } if (!string.IsNullOrEmpty(aniFxMgr.m_search)) { List <string> l = new List <string>(); foreach (var aniName in aniNames) { if (aniName.Contains(aniFxMgr.m_search)) { l.Add(aniName); } } aniNames = l.ToArray(); } EditorGUI.BeginChangeCheck(); using (new AutoBeginHorizontal()) { aniFxMgr.m_search = EditorGUILayout.TextField("筛选", aniFxMgr.m_search, "ToolbarSeachTextField", GUILayout.ExpandWidth(true)); if (GUILayout.Button("", string.IsNullOrEmpty(aniFxMgr.m_search) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton")) { aniFxMgr.m_search = ""; } } //测试元素属性 aniFxMgr.m_testElement = (enAniFxElement)EditorGUILayout.Popup("测试元素属性", (int)aniFxMgr.m_testElement, AniFxMgr.Element_Names); List <AniFxGroup> removes = new List <AniFxGroup>(); //绘制 foreach (AniFxGroup g in aniFxMgr.m_groups) { if (!string.IsNullOrEmpty(aniFxMgr.m_search) && !g.name.Contains(aniFxMgr.m_search)) { continue; } if (DrawGroup(g, aniFxMgr, ani, aniNames)) { removes.Add(g); } } //删除 foreach (AniFxGroup g in removes) { aniFxMgr.m_groups.Remove(g); } //添加 int idx = UnityEditor.EditorGUILayout.Popup("添加", -1, aniNames); if (idx != -1) { if (aniFxMgr.GetGroup(aniNames[idx]) == null) { AniFxGroup g = new AniFxGroup(); g.name = aniNames[idx]; aniFxMgr.m_groups.Add(g); } else { Debuger.LogError("{0}已经添加过了,不能重复添加", aniNames[idx]); } } if (EditorGUI.EndChangeCheck()) { //Debuger.Log("修改"); EditorUtil.SetDirty(aniFxMgr); } }