DebugWindow() private method

private DebugWindow ( GUIView view ) : void
view GUIView
return void
コード例 #1
0
        private void OnWindowSelected(object userdata, string[] options, int selected)
        {
            selected--;
            GUIView gUIView;

            if (selected >= 0)
            {
                List <GUIView> list = (List <GUIView>)userdata;
                gUIView = list[selected];
            }
            else
            {
                gUIView = null;
            }
            if (this.m_Inspected != gUIView)
            {
                if (this.m_InstructionOverlayWindow != null)
                {
                    this.m_InstructionOverlayWindow.Close();
                }
                this.m_Inspected = gUIView;
                if (this.m_Inspected != null)
                {
                    GUIViewDebuggerHelper.DebugWindow(this.m_Inspected);
                    this.m_Inspected.Repaint();
                }
                else
                {
                    GUIViewDebuggerHelper.StopDebugging();
                }
                this.instructionModeView.Unselect();
            }
            base.Repaint();
        }
コード例 #2
0
        private void OnWindowSelected(object userdata, string[] options, int selected)
        {
            GUIView view;

            selected--;
            if (selected >= 0)
            {
                List <GUIView> list = (List <GUIView>)userdata;
                view = list[selected];
            }
            else
            {
                view = null;
            }
            if (this.m_Inspected != view)
            {
                if (this.m_InstructionOverlayWindow != null)
                {
                    this.m_InstructionOverlayWindow.Close();
                }
                this.m_Inspected = view;
                if (this.m_Inspected != null)
                {
                    GUIViewDebuggerHelper.DebugWindow(this.m_Inspected);
                    this.m_Inspected.Repaint();
                }
                this.m_ListViewState.row = -1;
                this.m_ListViewState.selectionChanged = true;
                this.m_Instruction = null;
            }
            base.Repaint();
        }
コード例 #3
0
 private void OnDisable()
 {
     if (this.m_Inspected != null)
     {
         GUIViewDebuggerHelper.DebugWindow(this.m_Inspected);
     }
     if (this.m_InstructionOverlayWindow != null)
     {
         this.m_InstructionOverlayWindow.Close();
     }
 }
コード例 #4
0
 private void OnDisable()
 {
     if ((UnityEngine.Object) this.m_Inspected != (UnityEngine.Object)null)
     {
         GUIViewDebuggerHelper.DebugWindow(this.m_Inspected);
     }
     if (!((UnityEngine.Object) this.m_InstructionOverlayWindow != (UnityEngine.Object)null))
     {
         return;
     }
     this.m_InstructionOverlayWindow.Close();
 }
コード例 #5
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);
        }
コード例 #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 OnWindowSelected(object userdata, string[] options, int selected)
        {
            --selected;
            GUIView guiView = selected < 0 ? (GUIView)null : ((List <GUIView>)userdata)[selected];

            if ((UnityEngine.Object) this.m_Inspected != (UnityEngine.Object)guiView)
            {
                if ((UnityEngine.Object) this.m_InstructionOverlayWindow != (UnityEngine.Object)null)
                {
                    this.m_InstructionOverlayWindow.Close();
                }
                this.m_Inspected = guiView;
                if ((UnityEngine.Object) this.m_Inspected != (UnityEngine.Object)null)
                {
                    GUIViewDebuggerHelper.DebugWindow(this.m_Inspected);
                    this.m_Inspected.Repaint();
                }
                this.m_ListViewState.row = -1;
                this.m_ListViewState.selectionChanged = true;
                this.m_Instruction = (GUIViewDebuggerWindow.GUIInstruction)null;
            }
            this.Repaint();
        }
コード例 #8
0
        private void UpdateExploredGUIStyle(Vector2 screenPos)
        {
            GUIView mouseUnderView = GetViewUnderMouse(screenPos, m_ExploredViews);

            ExploredDrawInstructionIndex = -1;
            ExploredStyle = null;
            if (mouseUnderView != m_ExploredView)
            {
                if (m_ExploredView)
                {
                    GUIViewDebuggerHelper.StopDebugging();
                    // Debug.Log("Stop debugging: " + GetViewName(m_ExploredView));
                }

                m_ExploredView = CanInspectView(mouseUnderView) ? mouseUnderView : null;

                if (m_ExploredView)
                {
                    // Start debugging
                    GUIViewDebuggerHelper.DebugWindow(m_ExploredView);
                    // Debug.Log("Start debugging: " + GetViewName(m_ExploredView));

                    // Since we have attached the debugger, this view hasn't logged its repaint steps yet.
                    m_ExploredView.Repaint();
                }
            }

            if (m_ExploredView)
            {
                var drawInstructions = new List <IMGUIDrawInstruction>();
                GUIViewDebuggerHelper.GetDrawInstructions(drawInstructions);

                var localPosition = new Vector2(screenPos.x - mouseUnderView.screenPosition.x,
                                                screenPos.y - mouseUnderView.screenPosition.y);
                GUIStyle mouseUnderStyle = null;

                /** Note: no perfect way to find the style under cursor:
                 *  - Lots of style rect overlap
                 *  - by starting with the end, we hope to follow the "Last drawn instruction is the one on top"
                 *  - Some styles are "transparent" and drawn last (TabWindowBackground and such)
                 *  - We try to go with the smallest rect that fits
                 */
                Rect styleRect        = new Rect(0, 0, 10000, 10000);
                var  smallestRectArea = styleRect.width * styleRect.height;
                for (var i = drawInstructions.Count - 1; i >= 0; --i)
                {
                    var instr = drawInstructions[i];
                    if (instr.rect.Contains(localPosition) && smallestRectArea > instr.rect.width * instr.rect.height)
                    {
                        mouseUnderStyle              = instr.usedGUIStyle;
                        styleRect                    = instr.rect;
                        smallestRectArea             = instr.rect.width * instr.rect.height;
                        ExploredDrawInstructionIndex = i;

                        // Debug.Log(GetViewName(m_ExploredView) + " - Found Style: " + instr.usedGUIStyle.name);
                    }
                }

                if (Highlighter != null && mouseUnderStyle != null)
                {
                    var visualElement = m_ExploredView.windowBackend.visualTree as VisualElement;
                    if (visualElement != null)
                    {
                        // Debug.Log(GetViewName(m_ExploredView) + " - Highlight Style: " + mouseUnderStyle.name);
                        Highlighter.HighlightElement(visualElement, styleRect, mouseUnderStyle);
                    }
                }

                ExploredStyle = mouseUnderStyle;
            }
        }