Exemplo n.º 1
0
        public TextList <T> AddTextList <T>(string name, Dictionary <T, string> defaultValues, OnButtonSelect <T> eventCallback, int width, int height)
        {
            bool         flag = eventCallback != null;
            TextList <T> result;

            if (flag)
            {
                UIPanel uIPanel = this.m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel;
                uIPanel.name = "NumberedColorList";
                bool flag2 = string.IsNullOrEmpty(name);
                if (flag2)
                {
                    uIPanel.Find <UILabel>("Label").text = "";
                }
                else
                {
                    uIPanel.Find <UILabel>("Label").text = name;
                }
                UnityEngine.Object.Destroy(uIPanel.Find <UIDropDown>("Dropdown").gameObject);
                TextList <T> textList = new TextList <T>(uIPanel, defaultValues, width, height, name);
                textList.eventOnClick += delegate(T value)
                {
                    eventCallback(value);
                };
                result = textList;
            }
            else
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create colorPicker with no name or no event");
                result = null;
            }
            return(result);
        }
Exemplo n.º 2
0
        private void redrawButtons()
        {
            foreach (Transform transform in this.linesListPanel.transform)
            {
                UnityEngine.Object.Destroy(transform.gameObject);
            }
            foreach (KeyValuePair <T, string> current in this.m_itemsList)
            {
                UIButtonWithId itemButton = new GameObject
                {
                    transform =
                    {
                        parent = this.linesListPanel.transform
                    }
                }.AddComponent <UIButtonWithId>();
                itemButton.width  = this.linesListPanel.width;
                itemButton.height = 35f;
                TextList <T> .initButton(itemButton, "EmptySprite");

                itemButton.hoveredColor     = Color.gray;
                itemButton.pressedColor     = Color.black;
                itemButton.focusedColor     = Color.black;
                itemButton.color            = new Color(0f, 0f, 0f, 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          = current.Key;
                itemButton.eventClick += delegate(UIComponent component, UIMouseEventParameter eventParam)
                {
                    this.selectedItem = (T)((object)itemButton.id);
                    eventParam.Use();
                };
                itemButton.text = current.Value;
                itemButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
                itemButton.name = string.Format("[{1}] {0}", current.Value, current.Key);
            }
        }