示例#1
0
        /// <summary>
        /// Removes all the item that are associated with the owner.
        /// </summary>
        /// <param name="owner">The owner to look for.</param>
        public void RemoveItemsWithOwner(GameObject owner)
        {
            List <string> groupsToRemove = new List <string>();

            // Remove in reverse
            for (int i = mMenuItems.Count - 1; i >= 0; --i)
            {
                if (mMenuItems[i].mOwner == owner)
                {
                    DebugItemGroup group = GetItemGroup(mMenuItems[i].mGroupName, false);
                    group.RemoveDebugItem(mMenuItems[i].mDebugMenuItem);

                    if (group.ItemCount == 0 && !groupsToRemove.Contains(mMenuItems[i].mGroupName))
                    {
                        groupsToRemove.Add(mMenuItems[i].mGroupName);
                    }
                    mMenuItems.RemoveAt(i);
                }
            }

            for (int index = 0; index < groupsToRemove.Count; index++)
            {
                this.RemoveGroup(groupsToRemove[index]);
            }
        }
示例#2
0
        /// <summary>
        /// Removed the item with the provided id.
        /// </summary>
        /// <param name="urid">The id passed back by an add call.</param>
        public void RemoveItem(int urid)
        {
            string groupToRemove = null;

            for (int i = 0; i < mMenuItems.Count; ++i)
            {
                if (mMenuItems[i].mURID == urid)
                {
                    DebugItemGroup group = GetItemGroup(mMenuItems[i].mGroupName, false);
                    group.RemoveDebugItem(mMenuItems[i].mDebugMenuItem);

                    if (group.ItemCount == 0)
                    {
                        groupToRemove = mMenuItems[i].mGroupName;
                    }

                    mMenuItems.RemoveAt(i);
                    break;
                }
            }

            if (groupToRemove != null)
            {
                this.RemoveGroup(groupToRemove);
            }
        }
示例#3
0
 /// <summary>
 /// Call to remove an group from this page and destroy it.
 /// </summary>
 /// <param name="group">The group to remove and destroy.</param>
 public void RemoveGroup(DebugItemGroup group)
 {
     if (m_MenuGroups.Contains(group))
     {
         m_MenuGroups.Remove(group);
         Destroy(group.gameObject);
     }
 }
示例#4
0
 /// <summary>
 /// Call to add an group to this page.
 /// </summary>
 /// <param name="group">The group to add.</param>
 public void AddGroup(DebugItemGroup group)
 {
     if ((group != null) && (!m_MenuGroups.Contains(group)))
     {
         //group.transform.SetParent(this.transform, false);
         group.transform.SetParent(m_ContentArea.transform, false);
         m_MenuGroups.Add(group);
     }
 }
示例#5
0
        /// <summary>
        /// Adds a DebugMenu item to the correct group and tracking.
        /// </summary>
        /// <param name="groupName">The group to add to.</param>
        /// <param name="owner">The owner to associate with.</param>
        /// <param name="item">The debug menu item to add.</param>
        /// <returns>The unique id for this item/</returns>
        public int AddItem(string groupName, GameObject owner, DebugMenuItem item)
        {
            DebugItemGroup group = GetItemGroup(groupName, true);

            ItemCommonInfo info = new ItemCommonInfo();

            info.mDebugMenuItem = item;
            info.mGroupName     = groupName;
            info.mOwner         = owner;
            info.mURID          = mCurURID++;

            group.AddDebugItem(item);
            mMenuItems.Add(info);

            return(info.mURID);
        }
示例#6
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);
            }
        }
示例#7
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);
        }
示例#8
0
        /// <summary>
        /// Removed all item within a group.
        /// </summary>
        /// <param name="groupName">The group name to look for.</param>
        public void RemoveGroup(string groupName)
        {
            DebugItemGroup group = GetItemGroup(groupName, false);

            if (group != null)
            {
                List <DebugMenuItem> children = group.MenuItems;
                for (int index = 0; index < children.Count; index++)
                {
                    for (int i = mMenuItems.Count - 1; i >= 0; --i)
                    {
                        if (mMenuItems[i].mDebugMenuItem == children[index])
                        {
                            mMenuItems.RemoveAt(i);
                        }
                    }

                    Destroy(mMenuItems[index].mDebugMenuItem.gameObject);
                }

                m_ItemGroups.Remove(groupName);
                Destroy(group.gameObject);
            }
        }