void HandleInput()
        {
            if (DebugManager.instance.GetAction(DebugAction.PreviousDebugPanel) != 0f)
            {
                int index = m_SelectedPanel - 1;
                if (index < 0)
                {
                    index = m_UIPanels.Count - 1;
                }
                index = Mathf.Clamp(index, 0, m_UIPanels.Count - 1);
                ActivatePanel(index);
            }

            if (DebugManager.instance.GetAction(DebugAction.NextDebugPanel) != 0f)
            {
                int index = m_SelectedPanel + 1;
                if (index >= m_UIPanels.Count)
                {
                    index = 0;
                }
                index = Mathf.Clamp(index, 0, m_UIPanels.Count - 1);
                ActivatePanel(index);
            }

            if (DebugManager.instance.GetAction(DebugAction.Action) != 0f)
            {
                ActivateSelection();
            }

            if (DebugManager.instance.GetAction(DebugAction.MakePersistent) != 0f && m_SelectedWidget != null)
            {
                DebugManager.instance.TogglePersistent(m_SelectedWidget.GetWidget());
            }

            float moveHorizontal = DebugManager.instance.GetAction(DebugAction.MoveHorizontal);

            if (moveHorizontal != 0f)
            {
                ChangeSelectionValue(moveHorizontal);
            }

            float moveVertical = DebugManager.instance.GetAction(DebugAction.MoveVertical);

            if (moveVertical != 0f)
            {
                if (moveVertical < 0f)
                {
                    SelectNextItem();
                }
                else
                {
                    SelectPreviousItem();
                }
            }
        }
Exemple #2
0
        internal void ChangeSelection(DebugUIHandlerWidget widget, bool fromNext)
        {
            if (widget == null)
            {
                return;
            }

            if (m_SelectedWidget != null)
            {
                m_SelectedWidget.OnDeselection();
            }

            var prev = m_SelectedWidget;

            m_SelectedWidget = widget;
            SetScrollTarget(widget);

            if (!m_SelectedWidget.OnSelection(fromNext, prev))
            {
                if (fromNext)
                {
                    SelectNextItem();
                }
                else
                {
                    SelectPreviousItem();
                }
            }
            else
            {
                if (m_SelectedWidget == null || m_SelectedWidget.GetWidget() == null)
                {
                    m_CurrentQueryPath = string.Empty;
                }
                else
                {
                    m_CurrentQueryPath = m_SelectedWidget.GetWidget().queryPath;
                }
            }
        }
Exemple #3
0
        void HandleInput()
        {
            if (DebugManager.instance.GetAction(DebugAction.PreviousDebugPanel) != 0f)
            {
                SelectPreviousPanel();
            }

            if (DebugManager.instance.GetAction(DebugAction.NextDebugPanel) != 0f)
            {
                SelectNextPanel();
            }

            if (DebugManager.instance.GetAction(DebugAction.Action) != 0f)
            {
                ActivateSelection();
            }

            if (DebugManager.instance.GetAction(DebugAction.MakePersistent) != 0f && m_SelectedWidget != null)
            {
                DebugManager.instance.TogglePersistent(m_SelectedWidget.GetWidget());
            }

            float moveHorizontal = DebugManager.instance.GetAction(DebugAction.MoveHorizontal);

            if (moveHorizontal != 0f)
            {
                ChangeSelectionValue(moveHorizontal);
            }

            float moveVertical = DebugManager.instance.GetAction(DebugAction.MoveVertical);

            if (moveVertical != 0f)
            {
                if (moveVertical < 0f)
                {
                    SelectNextItem();
                }
                else
                {
                    SelectPreviousItem();
                }
            }
        }
Exemple #4
0
        void Rebuild()
        {
            // Check prefab associations
            m_PrefabsMap.Clear();
            foreach (var bundle in prefabs)
            {
                var type = Type.GetType(bundle.type);

                if (type != null && bundle.prefab != null)
                {
                    m_PrefabsMap.Add(type, bundle.prefab);
                }
            }

            m_UIPanels.Clear();

            m_DebugTreeState = DebugManager.instance.GetState();
            var panels = DebugManager.instance.panels;

#if UNITY_ANDROID || UNITY_IPHONE
            // Mobile device safe area
            Rect  parentRect  = GetComponentInParent <RectTransform>().rect;
            float parentWidth = Math.Min(parentRect.width, parentRect.height);
            float scaleRatio  = parentWidth / Math.Min(Screen.height, Screen.width);

            Rect    safeAreaRect       = Screen.safeArea;
            Vector2 margin             = new Vector2(5, 5);
            var     safeAreaOffsetLeft = safeAreaRect.xMin * scaleRatio;
            var     safeAreaOffsetTop  = -safeAreaRect.yMin * scaleRatio;
            Vector2 safeAreaOffset     = new Vector2(safeAreaOffsetLeft, safeAreaOffsetTop) + margin;
#endif

            DebugUIHandlerWidget selectedWidget = null;
            foreach (var panel in panels)
            {
                if (panel.isEditorOnly || panel.children.Count(x => !x.isEditorOnly && !x.isHidden) == 0)
                {
                    continue;
                }

                var go = Instantiate(panelPrefab, transform, false).gameObject;
                go.name = panel.displayName;

#if UNITY_ANDROID || UNITY_IPHONE
                RectTransform rectTransform = go.GetComponent <RectTransform>();
                rectTransform.anchoredPosition = safeAreaOffset;
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, safeAreaRect.height * scaleRatio + 2 * safeAreaOffsetTop);
#endif

                var uiPanel = go.GetComponent <DebugUIHandlerPanel>();
                uiPanel.SetPanel(panel);
                uiPanel.Canvas = this;
                m_UIPanels.Add(uiPanel);
                var container = go.GetComponent <DebugUIHandlerContainer>();
                DebugUIHandlerWidget selected = null;
                Traverse(panel, container.contentHolder, null, ref selected);

                if (selected != null && selected.GetWidget().queryPath.Contains(panel.queryPath))
                {
                    selectedWidget = selected;
                }
            }

            ActivatePanel(m_SelectedPanel, selectedWidget);
        }