GetViews() static private method

static private GetViews ( List views ) : void
views List
return void
示例#1
0
 public void StartExploreStyle()
 {
     // Debug.Log("Start Style Explorer");
     Assert.IsFalse(IsPicking);
     IsPicking = true;
     EditorApplication.update += FindStyleUnderMouse;
     GUIViewDebuggerHelper.GetViews(m_ExploredViews);
 }
        private void DoWindowPopup()
        {
            string t = "<Please Select>";

            if ((UnityEngine.Object) this.m_Inspected != (UnityEngine.Object)null)
            {
                t = GUIViewDebuggerWindow.GetViewName(this.m_Inspected);
            }
            GUILayout.Label("Inspected Window: ", new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(false)
            });
            Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[1] {
                GUILayout.ExpandWidth(true)
            });

            if (!GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown))
            {
                return;
            }
            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);
            List <GUIContent> guiContentList = new List <GUIContent>(views.Count + 1);

            guiContentList.Add(new GUIContent("None"));
            int            selected    = 0;
            List <GUIView> guiViewList = new List <GUIView>(views.Count + 1);

            for (int index = 0; index < views.Count; ++index)
            {
                GUIView view = views[index];
                if (this.CanInspectView(view))
                {
                    GUIContent guiContent = new GUIContent(guiContentList.Count.ToString() + ". " + GUIViewDebuggerWindow.GetViewName(view));
                    guiContentList.Add(guiContent);
                    guiViewList.Add(view);
                    if ((UnityEngine.Object)view == (UnityEngine.Object) this.m_Inspected)
                    {
                        selected = guiViewList.Count;
                    }
                }
            }
            EditorUtility.DisplayCustomMenu(rect, guiContentList.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), (object)guiViewList);
        }
示例#3
0
        static Rect GetRectOfObjectInGUIView(string viewName, UnityEngine.Object objectToFind, out bool found)
        {
            var allViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(allViews);

            var drawInstructions = new List <IMGUIDrawInstruction>(32);

            foreach (var view in allViews)
            {
                if (view.GetViewName() != viewName)
                {
                    continue;
                }                                                 //todo: we should have a way to reference the window without using its name

                GUIViewDebuggerHelper.DebugWindow(view);
                view.RepaintImmediately();
                GUIViewDebuggerHelper.GetDrawInstructions(drawInstructions);
                foreach (var drawInstruction in drawInstructions) //todo: we should have a way to reference hierarchy objects without using their names
                {
                    //If we can reference the object represented by the draw instruction, we can find it like this

                    /*if (drawInstruction.usedGUIContent.representedObject != null)
                     * {
                     *  if (drawInstruction.usedGUIContent.representedObject == objectToFind)
                     *  {
                     *      found = true;
                     *      return drawInstruction.rect;
                     *  }
                     * }*/

                    if (drawInstruction.usedGUIContent.text != objectToFind.name)
                    {
                        continue;
                    }
                    found = true;
                    return(drawInstruction.rect);
                }
                found = false;
                return(Rect.zero);
            }
            found = false;
            return(Rect.zero);
        }
        private void DoWindowPopup()
        {
            string t = "<Please Select>";

            if (this.m_Inspected != null)
            {
                t = GUIViewDebuggerWindow.GetViewName(this.m_Inspected);
            }
            GUILayout.Label("Inspected Window: ", new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });

            if (GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown))
            {
                List <GUIView> list = new List <GUIView>();
                GUIViewDebuggerHelper.GetViews(list);
                List <GUIContent> list2 = new List <GUIContent>(list.Count + 1);
                list2.Add(new GUIContent("None"));
                int            selected = 0;
                List <GUIView> list3    = new List <GUIView>(list.Count + 1);
                for (int i = 0; i < list.Count; i++)
                {
                    GUIView gUIView = list[i];
                    if (this.CanInspectView(gUIView))
                    {
                        string     text = list2.Count + ". " + GUIViewDebuggerWindow.GetViewName(gUIView);
                        GUIContent item = new GUIContent(text);
                        list2.Add(item);
                        list3.Add(gUIView);
                        if (gUIView == this.m_Inspected)
                        {
                            selected = list3.Count;
                        }
                    }
                }
                EditorUtility.DisplayCustomMenu(rect, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), list3);
            }
        }
        void DoWindowPopup()
        {
            string selectedName = inspected == null ? Styles.defaultWindowPopupText : GetViewName(inspected);

            GUILayout.Label(Styles.inspectedWindowLabel, GUILayout.ExpandWidth(false));

            Rect popupPosition = GUILayoutUtility.GetRect(GUIContent.Temp(selectedName), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(true));

            if (GUI.Button(popupPosition, GUIContent.Temp(selectedName), EditorStyles.toolbarDropDown))
            {
                List <GUIView> views = new List <GUIView>();
                GUIViewDebuggerHelper.GetViews(views);

                List <GUIContent> options = new List <GUIContent>(views.Count + 1);

                options.Add(EditorGUIUtility.TrTextContent("None"));

                int            selectedIndex   = 0;
                List <GUIView> selectableViews = new List <GUIView>(views.Count + 1);
                for (int i = 0; i < views.Count; ++i)
                {
                    GUIView view = views[i];

                    //We can't inspect ourselves, otherwise we get infinite recursion.
                    //Also avoid the InstructionOverlay
                    if (!CanInspectView(view))
                    {
                        continue;
                    }

                    GUIContent label = new GUIContent(string.Format("{0}. {1}", options.Count, GetViewName(view)));
                    options.Add(label);
                    selectableViews.Add(view);

                    if (view == inspected)
                    {
                        selectedIndex = selectableViews.Count;
                    }
                }
                //TODO: convert this to a Unity Window style popup. This way we could highlight the window on hover ;)
                EditorUtility.DisplayCustomMenu(popupPosition, options.ToArray(), selectedIndex, OnWindowSelected, selectableViews);
            }
        }
示例#6
0
        static Rect GetRectOfFieldInInspector(string fieldPathInClass, Type targetType, out bool found)
        {
            string viewName = nameof(InspectorWindow);
            var    allViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(allViews);

            var propertyInstructions = new List <IMGUIPropertyInstruction>(32);

            foreach (var view in allViews)
            {
                if (view.GetViewName() != viewName)
                {
                    continue;
                }                                                 //todo: we should have a way to reference the window without using its name

                GUIViewDebuggerHelper.DebugWindow(view);
                view.RepaintImmediately();
                GUIViewDebuggerHelper.GetPropertyInstructions(propertyInstructions);
                var targetTypeName = targetType.AssemblyQualifiedName;

                foreach (var instruction in propertyInstructions) //todo: we should have a way to reference hierarchy objects without using their names
                {
                    if (instruction.targetTypeName == targetTypeName &&
                        instruction.path == fieldPathInClass)
                    {
                        found = true;
                        return(instruction.rect);
                    }
                }
                var drawInstructions = new List <IMGUIDrawInstruction>(32);
                GUIViewDebuggerHelper.GetDrawInstructions(drawInstructions);

                // Property instruction not found
                // Let's see if we can find any of the ancestor instructions to allow the user to unfold
                Rect regionRect = new Rect();
                found = FindAncestorPropertyRegion(fieldPathInClass, targetTypeName, drawInstructions, propertyInstructions, ref regionRect);
                return(regionRect);
            }
            found = false;
            return(Rect.zero);
        }
示例#7
0
        private void DoWindowPopup()
        {
            string t = "<Please Select>";

            if (this.m_Inspected != null)
            {
                t = GetViewName(this.m_Inspected);
            }
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label("Inspected Window: ", options);
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
            Rect position = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, optionArray2);

            if (GUI.Button(position, GUIContent.Temp(t), EditorStyles.toolbarDropDown))
            {
                List <GUIView> views = new List <GUIView>();
                GUIViewDebuggerHelper.GetViews(views);
                List <GUIContent> list2 = new List <GUIContent>(views.Count + 1)
                {
                    new GUIContent("None")
                };
                int            selected = 0;
                List <GUIView> userData = new List <GUIView>(views.Count + 1);
                for (int i = 0; i < views.Count; i++)
                {
                    GUIView view = views[i];
                    if (this.CanInspectView(view))
                    {
                        GUIContent item = new GUIContent(list2.Count + ". " + GetViewName(view));
                        list2.Add(item);
                        userData.Add(view);
                        if (view == this.m_Inspected)
                        {
                            selected = userData.Count;
                        }
                    }
                }
                EditorUtility.DisplayCustomMenu(position, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), userData);
            }
        }
示例#8
0
        private void DoWindowPopup()
        {
            string t = (!(this.inspected == null)) ? GUIViewDebuggerWindow.GetViewName(this.inspected) : GUIViewDebuggerWindow.Styles.defaultWindowPopupText;

            GUILayout.Label(GUIViewDebuggerWindow.Styles.inspectedWindowLabel, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });

            if (GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown))
            {
                List <GUIView> list = new List <GUIView>();
                GUIViewDebuggerHelper.GetViews(list);
                List <GUIContent> list2 = new List <GUIContent>(list.Count + 1);
                list2.Add(EditorGUIUtility.TrTextContent("None", null, null));
                int            selected = 0;
                List <GUIView> list3    = new List <GUIView>(list.Count + 1);
                for (int i = 0; i < list.Count; i++)
                {
                    GUIView gUIView = list[i];
                    if (this.CanInspectView(gUIView))
                    {
                        GUIContent item = new GUIContent(string.Format("{0}. {1}", list2.Count, GUIViewDebuggerWindow.GetViewName(gUIView)));
                        list2.Add(item);
                        list3.Add(gUIView);
                        if (gUIView == this.inspected)
                        {
                            selected = list3.Count;
                        }
                    }
                }
                EditorUtility.DisplayCustomMenu(rect, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), list3);
            }
        }