Пример #1
0
 public override void OnInspectorGUI()
 {
     GUI.enabled = true;
     EditorGUILayout.BeginHorizontal();
     if (EditorGUIUtil.ObjectField <GameObject>("Root", ref root, true))
     {
         Classify(ref root);
     }
     if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false)) || root == null)
     {
         Classify(ref root);
     }
     GUI.enabled = root != null;
     if (GUILayout.Button("Rename", GUILayout.ExpandWidth(false)))
     {
         Rename();
     }
     GUI.enabled = true;
     EditorGUILayout.EndHorizontal();
     scroll = EditorGUILayout.BeginScrollView(scroll);
     VisualizeGroup();
     EditorGUIUtil.DrawSeparator();
     VisualizeDups();
     EditorGUILayout.EndScrollView();
 }
Пример #2
0
        private void DrawTextList()
        {
            EditorGUIUtil.DrawSeparator();

            if (!locked && Selection.gameObjects.IsNotEmpty() && (roots == null || !Enumerable.SequenceEqual(roots, Selection.gameObjects)))
            {
                Clear();
                // search labels
                roots = Selection.gameObjects;
                foreach (GameObject o in roots)
                {
                    tabs.Clear();
                    foreach (UITabHandler t in o.GetComponentsInChildren <UITabHandler>(true))
                    {
                        tabs.Add(new UITabHandlerInspectorImpl(t));
                    }
                }
                foreach (GameObject o in roots)
                {
                    // remove number labels
                    HashSet <UIText> ignore = new HashSet <UIText>();

                    foreach (DropDown dropdown in o.GetComponentsInChildren <DropDown>(true))
                    {
                        foreach (UIText l in dropdown.GetComponentsInChildren <UIText>(true))
                        {
                            ignore.Add(l);
                        }
                    }

                    foreach (UIText l in o.GetComponentsInChildren <UIText>(true))
                    {
                        if (l.text.IsEmpty())
                        {
                            continue;
                        }
                        if (ignore.Contains(l))
                        {
                            continue;
                        }
                        if (visibleOnly && (!l.gameObject.activeInHierarchy || !l.enabled))
                        {
                            continue;
                        }
                        foreach (char c in l.text)
                        {
                            if (char.IsLetter(c) && !char.IsWhiteSpace(c) && !char.IsPunctuation(c))
                            {
                                labels.Add(l);
                                break;
                            }
                        }
                    }
                }
            }
            foreach (UITabHandlerInspectorImpl inspector in tabs)
            {
                if (inspector.OnInspectorGUI())
                {
                    Save();
                    roots = null;
                }
            }

            // draw trigger list
            EditorGUILayout.BeginVertical();
            foreach (UIText l in labels)
            {
                if (!mod.ContainsKey(l))
                {
                    FindKey(l);
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.ObjectField(l, typeof(UIText), true);
                Color  oldColor = GUI.backgroundColor;
                string srcKey   = mod.Get(l);
                if (srcKey == null)
                {
                    srcKey = l.textKey;
                }
                if (!Lexicon.ContainsKey(srcKey))
                {
                    GUI.backgroundColor = Color.red;
                }
                string dstKey = EditorGUILayout.TextField(srcKey);
                GUI.backgroundColor = oldColor;
                string text = EditorGUILayout.TextField(l.text);
                if (srcKey != dstKey)
                {
                    mod[l] = dstKey;
                }
                if (text != l.text)
                {
                    l.SetText(text);
                    CompatibilityEditor.SetDirty(l);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Save"))
            {
                Save();
            }
        }
Пример #3
0
        private void DrawAudioTriggers()
        {
            EditorGUIUtil.Toggle("Lock", ref locked);
            // set missing triggers
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Missing");
            if (missingTriggerInspector.DrawInspectorGUI(ref missingTable, ref missingClip) && missingClip.IsNotEmpty())
            {
                foreach (AudioTriggerInspectorImpl i in triggers)
                {
                    if (i.trigger.audioGroupGuid.IsEmpty() || i.trigger.clip.IsEmpty())
                    {
                        i.SelectTable(missingTable);
                        i.trigger.clip = missingClip;
                        CompatibilityEditor.SetDirty(i.trigger);
                        changedList.Add(i.trigger.gameObject);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUIUtil.DrawSeparator();
            // Search AudioTriggers
            if ((roots.IsEmpty() || !locked) && Selection.gameObjects.IsNotEmpty() && !Array.Equals(roots, Selection.gameObjects))
            {
                Clear();
                roots = Selection.gameObjects;
                List <AudioTrigger> audio = new List <AudioTrigger> ();
                foreach (GameObject o in roots)
                {
                    foreach (UIButton btn in o.GetComponentsInChildren <UIButton>(true))
                    {
                        AudioTrigger[] t = btn.GetComponents <AudioTrigger> ();
                        if (t.IsEmpty())
                        {
                            t = new AudioTrigger[] { btn.gameObject.AddComponent <AudioTrigger> () };
                            changedList.Add(btn.gameObject);
                            CompatibilityEditor.SetDirty(btn.gameObject);
                        }
                        audio.AddRange(t);
                    }
                }
                AudioDataTable[] tables = AudioTriggerInspectorImpl.LoadTables();
                triggers = new AudioTriggerInspectorImpl[audio.Count];
                for (int i = 0; i < audio.Count; ++i)
                {
                    triggers [i]           = new AudioTriggerInspectorImpl(audio [i], tables);
                    triggers [i].showLabel = false;
                }
            }

            // draw trigger list
            EditorGUILayout.BeginVertical();
            foreach (AudioTriggerInspectorImpl a in triggers)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.ObjectField(a.trigger.gameObject, typeof(GameObject), true);
                if (a.DrawInspectorGUI())
                {
                    changedList.Add(a.trigger.gameObject);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Save"))
            {
                SaveChange(changedList);
                changedList.Clear();
            }
        }
Пример #4
0
    /// <summary>
    /// 中心区域的布局
    /// </summary>
    private void OnCenterGUI()
    {
        GUILayout.BeginVertical();

        centerScrollPos = EditorGUILayout.BeginScrollView(centerScrollPos);

        //绘制属性
        EditorGUIUtil.DrawHeader(actName + "属性");
        propertyScrollPos = EditorGUILayout.BeginScrollView(propertyScrollPos);

        List <EditorWidgetState> removes = null;

        foreach (EditorWidgetState obj in widgetList)
        {
            EditorGUI.indentLevel = 0;

            bool isRemove = EditorGUIUtil.OnGUIInstanceDisplay(obj, true);

            if (isRemove)
            {
                if (removes == null)
                {
                    removes = new List <EditorWidgetState>();
                }
                removes.Add(obj);
            }
        }

        //remove
        if (removes != null && removes.Count > 0)
        {
            foreach (EditorWidgetState ews in removes)
            {
                widgetList.Remove(ews);
            }
        }
        EditorGUILayout.EndScrollView();


        EditorGUIUtil.DrawSeparator();
        //添加新模块视图
        this.onAddNewModuleGUI();

        if (!string.IsNullOrEmpty(actName))
        {
            EditorGUIUtil.DrawSeparator();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            //保存数据到本地
            if (GUILayout.Button("Save"))
            {
                this.saveActFile(actGroup, actName, true);
            }
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        GUILayout.EndScrollView();
        GUILayout.Space(5F);
        GUILayout.EndVertical();
    }