Пример #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);
            }
        }