private void SetupDebugButtons()
    {
        //Sort groups, remove root & first as they have overriden sorting
        List <string> groupKeys = new List <string>(DebugLogConsole.consoleButtons.Keys);

        groupKeys.Remove("root");
        groupKeys.Remove("first");
        groupKeys.Sort();

        //Create group roots
        debugButtonGroups.Add("root", debugRootGroup);
        foreach (string groupKey in groupKeys)
        {
            RectTransform groupRoot = Instantiate(debugRootGroup, debugButtonGroupParent, false).GetComponent <RectTransform>();
            groupRoot.gameObject.name = groupKey + "Group";
            debugButtonGroups.Add(groupKey, groupRoot);
        }

        //
        //Generate the Root setup
        //
        //First
        if (DebugLogConsole.consoleButtons.ContainsKey("first"))
        {
            foreach (ConsoleButtonInfo debugButtonInfo in DebugLogConsole.consoleButtons["first"])
            {
                DebugButtonItem newDebugBtn = Instantiate <DebugButtonItem>(debugButtonPrefab, debugRootGroup, false);
                newDebugBtn.Setup(debugButtonInfo);
            }
        }
        //Groups
        foreach (string groupButton in groupKeys)
        {
            DebugButtonItem newDebugBtn = Instantiate <DebugButtonItem>(debugButtonPrefab, debugRootGroup, false);
            newDebugBtn.SetupGroup(groupButton);
        }
        //Root buttons last
        if (DebugLogConsole.consoleButtons.ContainsKey("root"))
        {
            foreach (ConsoleButtonInfo debugButtonInfo in DebugLogConsole.consoleButtons["root"])
            {
                DebugButtonItem newDebugBtn = Instantiate <DebugButtonItem>(debugButtonPrefab, debugRootGroup, false);
                newDebugBtn.Setup(debugButtonInfo);
            }
        }

        //
        //Setup each Group's setup
        //
        foreach (string groupKey in groupKeys)
        {
            //add a back button
            DebugButtonItem backBtn = Instantiate <DebugButtonItem>(debugButtonPrefab, debugButtonGroups[groupKey], false);
            backBtn.SetupBackButton();
            //add groups' buttons
            foreach (ConsoleButtonInfo debugButtonInfo in DebugLogConsole.consoleButtons[groupKey])
            {
                DebugButtonItem newDebugBtn = Instantiate <DebugButtonItem>(debugButtonPrefab, debugButtonGroups[groupKey], false);
                newDebugBtn.Setup(debugButtonInfo);
            }
            //disable this menu
            debugButtonGroups[groupKey].gameObject.SetActive(false);
        }
    }
Esempio n. 2
0
 protected sealed override void Register(DebugButtonItem widget)
 {
     widget.Label      = Label;
     widget.ButtonText = ButtonText;
     widget.OnClick    = OnClick;
 }