コード例 #1
0
    /********* Other **********/

    //Fill in MenuItems and the first section from what's already on the UI in the editor
    private void pickupUIElements()
    {
        string menuTitle = "Nameless menu";

        if (MenuTitle != null)
        {
            menuTitle = MenuTitle.text;
        }

        RPGMenuData currentMenu = new RPGMenuData(menuTitle);

        foreach (Transform trans in HostWindowCommandMenuContent.transform)
        {
            RPGMenuItem item = trans.GetComponent <RPGMenuItem>();
            if (item != null)
            {
                item.ParentMenu = this;
                menuItemsGO.Add(item);
                currentMenu.AddItem(item.MenuItemData);
            }
        }

        if (currentMenu.MenuItems.Count > 0)
        {
            //Add to current stack MenuSections
            if (MenuSections == null)
            {
                MenuSections = new Stack <RPGMenuData>();
            }

            MenuSections.Push(currentMenu);
            Debug.Log("Picking up UI: " + this.gameObject.name + " and creating new section");
        }
        else
        {
            Debug.LogError("Failed to pick up any menu items already in the menu (HostWindowCommandMenuContent). The data inside this menu might not have any RPGMenuItemData component attached?");
        }
    }