示例#1
0
        private void redrawButtons()
        {
            foreach (Transform t in linesListPanel.transform)
            {
                GameObject.Destroy(t.gameObject);
            }
            for (int j = 0; j < colorList.Count; j++)
            {
                GameObject itemContainer = new GameObject();

                itemContainer.transform.parent = linesListPanel.transform;
                UIButtonWithId itemButton = itemContainer.AddComponent <UIButtonWithId> ();

                itemButton.width  = 35;
                itemButton.height = 35;

                initButton(itemButton, "EmptySprite");
                itemButton.color        = colorList [j];
                itemButton.hoveredColor = itemButton.color;
                itemButton.pressedColor = itemButton.color;
                itemButton.focusedColor = itemButton.color;
                itemButton.textColor    = Color.white;
                itemButton.hoveredColor = itemButton.textColor;
                itemButton.id           = j + 1;
                itemButton.eventClick  += (component, eventParam) => {
                    if (eventOnClick != null)
                    {
                        eventOnClick(itemButton.id);
                    }
                };
                setLineNumberMainListing(j + 1, itemButton);
                itemButton.name = "Color #" + (j + 1);
            }
        }
示例#2
0
        private void redrawButtons()
        {
            foreach (Transform t in linesListPanel.transform)
            {
                GameObject.Destroy(t.gameObject);
            }
            foreach (var entry in m_itemsList)
            {
                GameObject itemContainer = new GameObject();

                itemContainer.transform.parent = linesListPanel.transform;
                UIButtonWithId itemButton = itemContainer.AddComponent <UIButtonWithId>();

                itemButton.width  = linesListPanel.width;
                itemButton.height = 35;

                initButton(itemButton, "EmptySprite");
                itemButton.hoveredColor     = Color.gray;
                itemButton.pressedColor     = Color.black;
                itemButton.focusedColor     = Color.black;
                itemButton.color            = new Color(0, 0, 0, 0.7f);
                itemButton.textColor        = Color.white;
                itemButton.focusedTextColor = Color.white;
                itemButton.hoveredTextColor = Color.white;
                itemButton.pressedTextColor = Color.white;
                itemButton.outlineColor     = Color.black;
                itemButton.useOutline       = true;
                itemButton.id          = entry.Key;
                itemButton.eventClick += (component, eventParam) =>
                {
                    selectedItem = (T)itemButton.id;
                    eventParam.Use();
                };
                itemButton.text = entry.Value;
                itemButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
                itemButton.name = string.Format("[{1}] {0}", entry.Value, entry.Key);
            }
        }