public static UIDropDown CloneBasicDropDownLocalized(string text, string[] options, OnDropdownSelectionChanged eventCallback, int defaultSelection, UIComponent parent, bool limitLabelByPanelWidth = false) { if (eventCallback != null && !string.IsNullOrEmpty(text)) { UIPanel uIPanel = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kDropdownTemplate)) as UIPanel; uIPanel.Find <UILabel>("Label").localeID = text; uIPanel.Find <UILabel>("Label").isLocalized = true; if (limitLabelByPanelWidth) { KlyteUtils.LimitWidth(uIPanel.Find <UILabel>("Label"), (uint)uIPanel.width); } UIDropDown uIDropDown = uIPanel.Find <UIDropDown>("Dropdown"); uIDropDown.items = options; uIDropDown.selectedIndex = defaultSelection; uIDropDown.eventSelectedIndexChanged += delegate(UIComponent c, int sel) { eventCallback(sel); }; return(uIDropDown); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create dropdown with no name or no event"); return(null); }
public UIHelperExtension AddTogglableGroup(string title, out UILabel toggleLabel) { if (m_GroupStates == null) { m_GroupStates = new Dictionary <string, DecorationPropertiesPanel.GroupInfo>(); } var newGroup = AddGroupExtended(title, out toggleLabel, out UIPanel parentPanel); toggleLabel.text = title; toggleLabel.stringUserData = title; toggleLabel.eventClick += new MouseEventHandler(OnGroupClicked); toggleLabel.backgroundSprite = "OptionsDropbox"; toggleLabel.padding = new RectOffset(10, 10, 10, 10); var uipanel = (UIPanel)newGroup.self; uipanel.Hide(); uipanel.autoFitChildrenVertically = false; uipanel.clipChildren = true; uipanel.autoFitChildrenHorizontally = true; uipanel.backgroundSprite = "OptionsDropboxListboxHovered"; uipanel.minimumSize = new Vector2(self.width - 20, 0); uipanel.maximumSize = uipanel.minimumSize; uipanel.padding = new RectOffset(10, 10, 10, 10); uipanel.size = new Vector2(newGroup.self.size.x, 0f); KlyteUtils.LimitWidth(toggleLabel, uipanel.width, true); parentPanel.autoLayoutPadding = new RectOffset(0, 0, 0, 0); m_GroupStates.Add(title, new DecorationPropertiesPanel.GroupInfo { m_Folded = true, m_Container = newGroup.self, m_PropertyContainer = uipanel }); return(newGroup); }