示例#1
0
        /// <summary>
        /// Sets a group to a page.  If no page exists, then a page is created.
        /// </summary>
        /// <param name="groupName">The group to assign to a page.</param>
        /// <param name="pageName">The name of the page to assign the group to.</param>
        public void SetGroupPage(string groupName, string pageName)
        {
            DebugItemGroup group = GetItemGroup(groupName, false);
            DebugPage      page  = GetPage(pageName, true);

            if (group != null)
            {
                // Remove from old group (ie, "Miscellaneous Items")
                DebugPage oldPage = GetPage(pageName, false);
                if (oldPage != null)
                {
                    oldPage.RemoveGroup(group);
                }

                // Add to the new group
                page.AddGroup(group);
            }
        }
示例#2
0
        /// <summary>
        /// Gets the group item or creates one if it does not exist.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="allowCreate">If true will create a group if it does not exist.  If fall it will return null if a group does not exist.</param>
        /// <returns>The group item or null if the group does not exist and allowCreate is false.</returns>
        private DebugItemGroup GetItemGroup(string groupName, bool allowCreate)
        {
            DebugItemGroup group = null;

            if (m_ItemGroups.ContainsKey(groupName))
            {
                group = m_ItemGroups[groupName];
            }
            else if (allowCreate)
            {
                group       = Instantiate(DebugItemGroupPrefab) as DebugItemGroup;
                group.Title = groupName;

                m_ItemGroups[groupName] = group;

                // Set to the default page
                DebugPage page = GetPage("Miscellaneous Items", true);
                page.AddGroup(group);
            }

            return(group);
        }
示例#3
0
        /// <summary>
        /// Gets a page or creates one if it does not exist.
        /// </summary>
        /// <param name="pageName">The name of the page.</param>
        /// <param name="allowCreate">If true will create a page if it does not exist.  If fall it will return null if a group does not exist.</param>
        /// <returns>The page or null if the page does not exist and allowCreate is false.</returns>
        private DebugPage GetPage(string pageName, bool allowCreate, bool startDisabled = true)
        {
            DebugPage page = null;

            if (m_Pages.ContainsKey(pageName))
            {
                page = m_Pages[pageName];
            }
            else if (allowCreate)
            {
                UnityEngine.Debug.Log("Creating new page: " + pageName);
                page       = Instantiate(DebugPagePrefab) as DebugPage;
                page.Title = pageName;

                m_Pages[pageName] = page;
                page.transform.SetParent(m_MenuContainer.transform, false);

                m_PageKeys.Add(pageName);

                m_PageDirty = true;
            }

            return(page);
        }