Exemple #1
0
        public override void OnGUI()
        {
            base.OnGUI();
            Title("ScriptField");
            v = GUILayout.BeginScrollView(v);
            OnGUIUtility.ScriptField("this Script", GetType());
            Title("EditorPrefsFoldoutGroup");
            if (OnGUIUtility.EditorPrefsFoldoutGroup("FoldoutGroup"))
            {
                GUILayout.Label("FoldoutContent");
                GUILayout.Label("FoldoutContent");
                GUILayout.Label("FoldoutContent");
            }
            Title("ObjectPopupWindow");
            if (GUILayout.Button("ObjectPopupWindow.Show"))
            {
                ObjectPopupWindow.Show(this);
            }
            Title("SelectWindow");
            if (GUILayout.Button("SelectWindow<T>.Show"))
            {
                SelectWindow <string> .Show(strlist, "1");
            }
            if (SelectWindow <string> .CanPick("1"))
            {
                var t = SelectWindow <string> .GetPick();

                Debug.Log(t);
            }
            Title("OnGUIUtility.Search");
            var s = search.OnToolbarGUI();

            Title("OnGUIUtility.Zone_Divide2Horizontal");
            zone_Horizon.OnGUILayout(window.Repaint, () =>
            {
                GUILayout.Button("1");
                GUILayout.Button("1");
                GUILayout.Button("1");
                GUILayout.Button("1");
                OnGUIUtility.Debug.HolderBox();
            },
                                     () =>
            {
                SubZone_Horizon.OnGUILayout(window.Repaint, () =>
                {
                    GUILayout.Button("2");
                    GUILayout.Button("2");
                    OnGUIUtility.Debug.HolderBox();
                    GUILayout.Button("2");
                    SubZOne_Vertical.OnGUILayout(window.Repaint, () =>
                    {
                        GUILayout.Button("3");
                        GUILayout.Button("3");
                        OnGUIUtility.Debug.HolderBox();
                        GUILayout.Button("3");
                    },
                                                 () =>
                    {
                        GUILayout.Button("3");
                        OnGUIUtility.Debug.HolderBox();
                        GUILayout.Button("3");
                    });
                },
                                            () =>
                {
                    GUILayout.Button("2");
                    OnGUIUtility.Debug.HolderBox();
                    GUILayout.Button("2");
                });
            });
            EditorGUILayout.MinMaxSlider("111", ref min, ref max, 0, 100);
            Title("SeanlibEditor.Styles");
            GUILayout.Button("SeanLibEditor.styles.Area", SeanLibEditor.styles.ExtendArea, GUILayout.Width(200));
            GUILayout.Button("SeanLibEditor.styles.Group", SeanLibEditor.styles.ExtendGroup, GUILayout.Width(200));
            GUILayout.Button("SeanLibEditor.styles.Title", SeanLibEditor.styles.Title, GUILayout.Width(200));
            GUILayout.EndScrollView();
            Title("GUIGifDrawer.OnGUI");
            gifDrawer.OnGUI(this.window.Repaint);
            gifDrawer1.OnGUI(this.window.Repaint);
        }
        public void OnGUI()
        {
            if (!ReferenceRoot.Instance)
            {
                EditorGUILayout.HelpBox("Scene need RefrenceRoot", MessageType.Error);
                if (GUILayout.Button("Create Root"))
                {
                    CreateReferenceRoot();
                }
                return;
            }
            EditorGUILayout.BeginHorizontal();
            {
                ShowMode.OnGui(EditorStyles.toolbarButton);
                search.OnToolbarGUI();
                if (GUILayout.Button("Refresh", EditorStyles.toolbarButton))
                {
                    RefreshData();
                }
                if (Event.current.type == EventType.Layout && Event.current.keyCode == KeyCode.R)
                {
                    RefreshData();
                }
                if (Event.current.type == EventType.Layout && Missing)
                {
                    RefreshData();
                    Missing = false;
                }
            }
            EditorGUILayout.EndHorizontal();

            v = EditorGUILayout.BeginScrollView(v);
            {
                if (ShowMode.IsEnable(0))
                {
                    foreach (var objPair in AllDic)
                    {
                        if (objPair.Key == null)
                        {
                            Missing = true;
                            break;
                        }
                        if (filtRefObj(objPair.Key))
                        {
                            bool hasConflit = objPair.Value;
                            OnGUIUtility.Vision.BeginBackGroundColor(hasConflit ? Color.red : Color.white);
                            EditorGUILayout.BeginHorizontal();
                            {
                                GUILayout.Label(objPair.Key.Data.GUID, GUILayout.MaxWidth(100));
                                if (GUILayout.Button(objPair.Key.gameObject.name, OnGUIUtility.Styles.Title))
                                {
                                    Selection.activeGameObject = objPair.Key.gameObject;
                                }
                                if (hasConflit)
                                {
                                    if (GUILayout.Button("New", GUILayout.MaxWidth(64)))
                                    {
                                        NewGUID(objPair.Key);
                                        return;
                                    }
                                    if (GUILayout.Button(objPair.Value.gameObject.name, OnGUIUtility.Styles.Title))
                                    {
                                        Selection.activeGameObject = objPair.Value.gameObject;
                                    }
                                    if (GUILayout.Button("New", GUILayout.MaxWidth(64)))
                                    {
                                        NewGUID(objPair.Value);
                                        return;
                                    }
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            OnGUIUtility.Vision.EndBackGroundColor();
                        }
                    }
                }
                else if (ShowMode.IsEnable(1))
                {
                    FieldDrawerUtil.ObjectField("测试资源", TestAssets);
                    foreach (var reference in References)
                    {
                        if (filtReference(reference))
                        {
                            var   refobj = ReferenceRoot.Instance.Get(reference.Identity);
                            Color color  = Color.white;
                            if (!refobj)
                            {
                                color = OnGUIUtility.Colors.red;
                            }
                            if (reference.Dynamic)
                            {
                                color = OnGUIUtility.Colors.blue;
                            }
                            OnGUIUtility.Vision.BeginBackGroundColor(color);
                            EditorGUILayout.BeginHorizontal();
                            {
                                var title = reference.Identity;
                                if (reference.Dynamic)
                                {
                                    title = "(" + reference.DyamicName + ")" + reference.Identity;
                                }
                                GUILayout.Label(title, GUILayout.MaxWidth(150));
                                if (refobj)
                                {
                                    if (GUILayout.Button(refobj.gameObject.name, OnGUIUtility.Styles.Title))
                                    {
                                        Selection.activeGameObject = refobj.gameObject;
                                    }
                                }
                                else
                                {
                                    if (GUILayout.Button("Null", OnGUIUtility.Styles.Title))
                                    {
                                        ObjectPopupWindow.Show(reference);
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            OnGUIUtility.Vision.EndBackGroundColor();
                        }
                    }
                }
                else if (ShowMode.IsEnable(2))
                {
                    OnGUIUtility.Vision.BeginBackGroundColor(Color.blue);
                    foreach (var item in ReferenceRoot.Instance.DynamicNameDic)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.SelectableLabel(item.Key, GUILayout.MaxWidth(100));
                            EditorGUILayout.SelectableLabel(item.Value, GUILayout.MaxWidth(300));
                            var refObj = ReferenceRoot.Instance.GetDynamic(item.Key);
                            if (refObj)
                            {
                                if (GUILayout.Button(refObj.gameObject.name, OnGUIUtility.Styles.Title))
                                {
                                    Selection.activeGameObject = refObj.gameObject;
                                }
                            }
                            else
                            {
                                GUILayout.Button("Null", OnGUIUtility.Styles.Title);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    OnGUIUtility.Vision.EndBackGroundColor();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Atts.Clear();
            var atts = fieldInfo.GetCustomAttributes(typeof(InspectorPlus.InspectorPlusAttribute), true);

            foreach (var item in atts)
            {
                Atts[item.GetType()] = item as InspectorPlus.InspectorPlusAttribute;
            }
            Rect rect = position;

            if (Event.current.type == EventType.Repaint)
            {
                var line = TryGetAttibute <InspectorPlus.Line>();
                if (line != null)
                {
                    switch (line.m_type)
                    {
                    case InspectorPlus.Line.LineType.Normal:
                        EditorGUI.DrawRect(new Rect(position.position, new Vector2(position.width, 2)), Color.grey);
                        rect = rect.Delta(new Vector2(0, 2));
                        break;

                    default:
                        break;
                    }
                }
            }
            if (TryGetAttibute <InspectorPlus.HideInInspector>() != null)
            {
                return;
            }
            var read = TryGetAttibute <InspectorPlus.ReadOnly>();

            if (read != null)
            {
                OnGUIUtility.Vision.GUIGlobleEnable(false);
            }
            var popup = TryGetAttibute <InspectorPlus.PopupObject>();

            if (popup != null)
            {
                object value = PropertyDrawerTools.GetPropertyInstance(property, fieldInfo);
                string title = popup.title.IsNullOrEmpty() ? label.text : popup.title;
                if (GUI.Button(position, title))
                {
                    property.serializedObject.Update();
                    ObjectPopupWindow.Show(value, new Vector2(popup.width, popup.heigth), title, () =>
                    {
                        //this may help in prefab mode
                        PrefabUtility.RecordPrefabInstancePropertyModifications(property.serializedObject.targetObject);
                        property.serializedObject.ApplyModifiedProperties();

                        EditorUtility.SetDirty(property.serializedObject.targetObject);
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                    });
                }
            }
            else
            {
                OnDraw(rect, property, label);
            }
            if (read != null)
            {
                OnGUIUtility.Vision.GUIGlobleEnable(true);
            }
        }