Пример #1
0
 public void Reset()
 {
     Target   = null;
     IsExpand = false;
     Parent   = null;
     Childrens.Clear();
 }
        /// <summary>
        /// 收集调试器游戏对象及子物体
        /// </summary>
        private void CollectDebuggerGameObject(Transform transform, DebuggerGameObject parent)
        {
            DebuggerGameObject gameObject = Main.m_ReferencePool.Spawn <DebuggerGameObject>();

            gameObject.Target = transform.gameObject;
            gameObject.Name   = transform.gameObject.name;
            gameObject.Layer  = LayerMask.LayerToName(transform.gameObject.layer);
            gameObject.IsMain = gameObject.Target.GetComponent <Main>();
            gameObject.Parent = parent;
            _gameObjects.Add(gameObject);

            if (gameObject.Parent != null)
            {
                gameObject.Parent.Childrens.Add(gameObject);
            }
            else
            {
                GameObjectRoots.Add(gameObject);
            }

            for (int i = 0; i < transform.childCount; i++)
            {
                CollectDebuggerGameObject(transform.GetChild(i), gameObject);
            }
        }
Пример #3
0
 public void Reset()
 {
     Target   = null;
     Name     = null;
     Layer    = null;
     IsMain   = false;
     IsExpand = false;
     Parent   = null;
     Childrens.Clear();
 }
Пример #4
0
        /// <summary>
        /// 调试器游戏对象UI
        /// </summary>
        private void OnGameObjectGUI(DebuggerGameObject gameObject)
        {
            GUILayout.BeginHorizontal();
            GUI.contentColor = gameObject.Target ? (gameObject.Target.activeSelf ? Color.cyan : Color.gray) : Color.red;
            bool value = _debuggerScene.CurrentGameObject == gameObject;

            if (GUILayout.Toggle(value, gameObject.Name) != value)
            {
                if (_debuggerScene.CurrentGameObject != gameObject)
                {
                    _debuggerScene.CurrentGameObject = gameObject;
                }
                else
                {
                    _debuggerScene.CurrentGameObject = null;
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (_debuggerScene.CurrentGameObject == gameObject && gameObject.Target)
            {
                GUILayout.BeginVertical("Box");

                GUILayout.BeginHorizontal();
                GUI.enabled      = gameObject.Name != "HTFramework";
                GUI.contentColor = gameObject.Target.activeSelf ? Color.white : Color.gray;
                bool active = GUILayout.Toggle(gameObject.Target.activeSelf, GetWord("Active"));
                if (active != gameObject.Target.activeSelf)
                {
                    gameObject.Target.SetActive(active);
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(GetWord("Delete")))
                {
                    Main.Kill(gameObject.Target);
                    _debuggerScene.Refresh();
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label(GetWord("Tag") + ": " + gameObject.Target.tag);
                GUILayout.Label(GetWord("Layer") + ": " + gameObject.Layer);
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }
        }
Пример #5
0
        /// <summary>
        /// 调试器游戏对象UI(层级模式)
        /// </summary>
        private void OnGameObjectGUILevel(DebuggerGameObject gameObject, int level)
        {
            GUILayout.BeginHorizontal();
            GUI.contentColor = gameObject.Target ? (gameObject.Target.activeSelf ? Color.cyan : Color.gray) : Color.red;
            if (gameObject.Childrens.Count > 0)
            {
                GUILayout.Space(20 * level);
                if (GUILayout.Button(gameObject.IsExpand ? _expandTexture : _retractTexture, "Label", GUILayout.Width(16), GUILayout.Height(16)))
                {
                    gameObject.IsExpand = !gameObject.IsExpand;
                }
            }
            else
            {
                GUILayout.Space(20 * level + 20);
            }
            bool value = _debuggerScene.CurrentGameObject == gameObject;

            if (GUILayout.Toggle(value, gameObject.Name) != value)
            {
                if (_debuggerScene.CurrentGameObject != gameObject)
                {
                    _debuggerScene.CurrentGameObject = gameObject;
                }
                else
                {
                    _debuggerScene.CurrentGameObject = null;
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (_debuggerScene.CurrentGameObject == gameObject && gameObject.Target)
            {
                GUILayout.BeginVertical("Box");

                GUILayout.BeginHorizontal();
                GUI.enabled      = gameObject.Name != "HTFramework";
                GUI.contentColor = gameObject.Target.activeSelf ? Color.white : Color.gray;
                bool active = GUILayout.Toggle(gameObject.Target.activeSelf, GetWord("Active"));
                if (active != gameObject.Target.activeSelf)
                {
                    gameObject.Target.SetActive(active);
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(GetWord("Delete")))
                {
                    Main.Kill(gameObject.Target);
                    _debuggerScene.Refresh();
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label(GetWord("Tag") + ": " + gameObject.Target.tag);
                GUILayout.Label(GetWord("Layer") + ": " + gameObject.Layer);
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }

            if (gameObject.IsExpand)
            {
                for (int i = 0; i < gameObject.Childrens.Count; i++)
                {
                    OnGameObjectGUILevel(gameObject.Childrens[i], level + 1);
                }
            }
        }