예제 #1
0
        void CalculateRects(ItemGroup items, Vector2 position, Vector2 offset)
        {
            float maxWidth = minWidth, curHeight = 0;

            minHeight = GUI.skin.label.CalcSize(items.Get(0).content).y + 4;

            foreach (MenuItem item in items)
            {
                if (item.content.text == "Saparator")
                {
                    curHeight += 3;
                }
                else
                {
                    maxWidth   = Mathf.Max(maxWidth, GUI.skin.label.CalcSize(item.content).x + (item.Group ? GroupIconSize : 0) + 20);
                    curHeight += minHeight;
                }
            }
            bool right = (position.x + offset.x + maxWidth < boundingRect.xMax) ? true : false;
            bool down  = (position.y + offset.y + curHeight < boundingRect.yMax) ? true : false;

            items.position = new Rect(position + new Vector2((right) ? offset.x : -(offset.x + maxWidth), (down) ? -offset.y : (offset.y - curHeight)), new Vector2(maxWidth, curHeight));
            curHeight      = 0;

            foreach (MenuItem item in items)
            {
                if (item.content.text == "Saparator")
                {
                    item.position = new Rect(0, curHeight, maxWidth, 3);
                    curHeight    += 3;
                }
                else
                {
                    item.position = new Rect(0, curHeight, maxWidth, minHeight);

                    if (item.Group)
                    {
                        CalculateRects(item.subItems, items.position.position + item.position.center, item.position.size / 2);
                    }
                    curHeight += minHeight;
                }
            }

            if (curHeight != items.position.height)
            {
                throw new UnityException();
            }
        }
예제 #2
0
 private ItemGroup GetItemGroup(int id,
                                out bool cachedAdd, out bool cachedChange, out bool cachedRemove)
 {
     cachedAdd    = false;
     cachedChange = false;
     cachedRemove = false;
     foreach (ItemGroup itemGroup in _itemGroupsAdded.Where(itemGroup => itemGroup.Id == id))
     {
         cachedAdd = true;
         return(itemGroup);
     }
     foreach (ItemGroup itemGroup in _itemGroupsNeedingUpdate.Where(itemGroup => itemGroup.Id == id))
     {
         cachedChange = true;
         return(itemGroup);
     }
     foreach (ItemGroup itemGroup in _itemGroupsRemoved.Where(itemGroup => itemGroup.Id == id))
     {
         cachedRemove = true;
         return(itemGroup);
     }
     return(ItemGroup.Get(id));
 }