Ejemplo n.º 1
0
        private void CreatePopup(int count, MCMenu parent)
        {
            // Get the Menu object, we need this because we have a button that closes the menu.
            MCMenu popupMenu = MenuController.GetMenuGlobal("SIMPLEPOPUP");

            // Create the data for the menu.
            MCSimplePopupData simplePopupData = new MCSimplePopupData("title " + count, "This is another popup.",
                                                                      new MCButtonData[]
            {
                new MCButtonData("New popup", button => { CreatePopup(count + 1, popupMenu); }, null, true, "Creates a new popup"),
                new MCButtonData("Tooltip", null, null, true, "Simply shows the tooltip working"),
                new MCButtonData("Close parent", button => { MenuController.HideMenuGlobal(popupMenu.Parent); }, null, true, "Closes the parent menu (which will close all children)"),
                new MCButtonData("Close this", button => popupMenu.Hide(), null, true, "Closes this popup")
            });

            if (parent)
            {
                parent.AddPopup(popupMenu, simplePopupData);
            }
            else
            {
                // Add the popup to the screen, when there is nothing on the screen it will be added as a menu instead of a popup.
                MenuController.AddPopupGlobal(popupMenu, true, simplePopupData);

                // In case you have a specific menucontroller that you want to use:
                // yourMenuController.AddPopup(popupMenu, true, simplePopupData);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a popup with an id to an existing menu.
        /// </summary>
        /// <param name="id">The id of the new popup.</param>
        /// <param name="parent">The parent object that already exists.</param>
        /// <param name="data">Data that should be passed on to the popup that is created.</param>
        /// <returns></returns>
        public MCMenu AddPopup(string id, MCMenu parent, object data = null)
        {
#if UNITY_EDITOR
            if (string.IsNullOrWhiteSpace(id))
            {
                Debug.LogError("You are trying to add a popup, but the id is empty. This is probably a mistake.");
            }
#endif
            return(parent.AddPopup(GetPoolObject(id), data));
        }