private void AddButton(string buttonName, int layerDepth, Dictionary <string, DebugPanelComponent> currentTree, UnityAction action, bool functional)
    {
        if (layerDepth >= DebugButtonColumns.Count)
        {
            DebugPanelColumn column = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.DebugPanelColumn].AllocateGameObject <DebugPanelColumn>(ColumnContainer);
            DebugButtonColumns.Add(column);
        }

        string[] paths = buttonName.Split('/');

        DebugPanelColumn currentColumn = DebugButtonColumns[layerDepth];

        if (!currentTree.ContainsKey(paths[0]))
        {
            DebugPanelButton btn = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.DebugPanelButton].AllocateGameObject <DebugPanelButton>(currentColumn.transform);
            btn.Initialize(paths[0], (paths.Length == 1 && functional)
                ? action
                : ToggleSubColumn(btn, currentTree));
            btn.gameObject.SetActive(layerDepth == 0);
            currentTree.Add(paths[0], btn);
        }

        if (paths.Length > 1)
        {
            string remainingPath = buttonName.Replace(paths[0] + "/", "");
            AddButton(remainingPath, layerDepth + 1, currentTree[paths[0]].DebugComponentDictTree, action, functional);
        }
    }
예제 #2
0
        private void AddButton(string buttonName, int layerDepth, Dictionary <string, DebugPanelButton> currentTree, UnityAction action)
        {
            if (layerDepth >= DebugButtonColumns.Count)
            {
                DebugPanelColumn column = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.DebugPanelColumn].AllocateGameObject <DebugPanelColumn>(ColumnContainer);
                DebugButtonColumns.Add(column);
            }

            string[] paths = buttonName.Split('/');

            DebugPanelColumn currentColumn = DebugButtonColumns[layerDepth];

            if (!currentTree.ContainsKey(paths[0]))
            {
                DebugPanelButton btn = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.DebugPanelButton].AllocateGameObject <DebugPanelButton>(currentColumn.transform);
                btn.Initialize(paths[0], paths.Length == 1
                    ? action
                    : () =>
                {
                    btn.IsOpen = !btn.IsOpen;
                    foreach (KeyValuePair <string, DebugPanelButton> kv in currentTree)
                    {
                        if (kv.Value != btn && btn.IsOpen)
                        {
                            kv.Value.IsOpen = false;
                        }
                    }
                });
                btn.gameObject.SetActive(layerDepth == 0);
                currentTree.Add(paths[0], btn);
            }

            if (paths.Length > 1)
            {
                string remainingPath = buttonName.Replace(paths[0] + "/", "");
                AddButton(remainingPath, layerDepth + 1, currentTree[paths[0]].DebugButtonDictTree, action);
            }
        }