public static void InitCircledButtonText(UIComponent parent, out UIButton button, string text, MouseEventHandler onClicked, string tooltip, float size = 40) { KlyteMonoUtils.CreateUIElement(out button, parent.transform, tooltip, new UnityEngine.Vector4(0, 0, size, size)); KlyteMonoUtils.InitButtonFull(button, false, "OptionBase"); button.focusedBgSprite = ""; button.text = text; button.eventClicked += onClicked; button.tooltip = tooltip; }
public static void CreateTabsComponent(out UITabstrip tabstrip, out UITabContainer tabContainer, Transform parentStrip, Transform parentContainer, string namePrefix, Vector4 areaTabstrip, Vector4 areaContainer) { KlyteMonoUtils.CreateUIElement(out tabstrip, parentStrip, $"{namePrefix}_Tabstrip", areaTabstrip); KlyteMonoUtils.CreateUIElement(out tabContainer, parentContainer, $"{namePrefix}_TabContainer", areaContainer); tabstrip.tabPages = tabContainer; tabstrip.selectedIndex = 0; tabstrip.selectedIndex = -1; }
public static void InitCircledButton(UIComponent parent, out UIButton button, string sprite, MouseEventHandler onClicked, string name, float size = 40) { KlyteMonoUtils.CreateUIElement(out button, parent.transform, name, new UnityEngine.Vector4(0, 0, size, size)); KlyteMonoUtils.InitButtonFull(button, false, "OptionBase"); button.focusedBgSprite = ""; button.normalFgSprite = sprite; button.scaleFactor = 0.6f; button.eventClicked += onClicked; button.tooltip = name; }
public static UIButton CreateTabTemplate(out UISprite logo, Vector2 size, UITextureAtlas textureAtlas = null) { KlyteMonoUtils.CreateUIElement(out UIButton tabTemplate, null, "UVMTabTemplate"); KlyteMonoUtils.InitButton(tabTemplate, false, "GenericTab"); tabTemplate.autoSize = false; tabTemplate.size = size; KlyteMonoUtils.CreateUIElement(out logo, tabTemplate.transform, "TabIcon", new Vector4(0, 0, size.x, size.y)); logo.atlas = textureAtlas ?? tabTemplate.atlas; return(tabTemplate); }
private void Awake() { m_pagePanel = GetComponent <UIPanel>(); m_pagePanel.padding = new RectOffset(0, 0, 0, 0); m_pagePanel.autoLayout = true; m_pagePanel.autoLayoutDirection = LayoutDirection.Horizontal; m_pagePanel.autoLayoutPadding = new RectOffset(0, 0, 0, 3); m_pagePanel.clipChildren = true; float height = m_pagePanel.height; KlyteMonoUtils.CreateUIElement(out m_infoLabel, m_pagePanel.transform, "infoLabel", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .4f, height)); m_infoLabel.verticalAlignment = UIVerticalAlignment.Middle; m_infoLabel.minimumSize = new Vector2(m_pagePanel.width * .4f, height); KlyteMonoUtils.LimitWidthAndBox(m_infoLabel, m_pagePanel.width * .4f); KlyteMonoUtils.CreateUIElement(out UILabel itemsPerPageLbl, m_pagePanel.transform, "itemsPerPageLbl", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .2f, height)); itemsPerPageLbl.verticalAlignment = UIVerticalAlignment.Middle; itemsPerPageLbl.text = Locale.Get("K45_CMNS_ITEMSPERPAGE"); itemsPerPageLbl.minimumSize = new Vector2(m_pagePanel.width * .2f, height); itemsPerPageLbl.textAlignment = UIHorizontalAlignment.Right; KlyteMonoUtils.LimitWidthAndBox(itemsPerPageLbl, m_pagePanel.width * .2f); m_itemsPerPageDD = UIHelperExtension.CloneBasicDropDownNoLabel( m_allowedItemCount.Select(x => x.ToString("0")).ToArray(), (idx) => { if (idx >= 0) { SetItemsPerpage(m_allowedItemCount[idx]); } }, m_pagePanel); m_itemsPerPageDD.area = new Vector4(0, 0, m_pagePanel.width * .1f, height); KlyteMonoUtils.CreateUIElement(out m_firstPage, m_pagePanel.transform, "firstPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); KlyteMonoUtils.InitButton(m_firstPage, false, "ButtonMenu"); m_firstPage.text = "<<"; m_firstPage.eventClicked += (x, y) => GoToPage(1); KlyteMonoUtils.CreateUIElement(out m_backPage, m_pagePanel.transform, "backPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); KlyteMonoUtils.InitButton(m_backPage, false, "ButtonMenu"); m_backPage.text = "<"; m_backPage.eventClicked += (x, y) => GoToPage(m_currentPage - 1); KlyteMonoUtils.CreateUIElement(out m_pageInput, m_pagePanel.transform, "firstPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); KlyteMonoUtils.UiTextFieldDefaults(m_pageInput); m_pageInput.horizontalAlignment = UIHorizontalAlignment.Right; m_pageInput.numericalOnly = true; m_pageInput.allowNegative = false; m_pageInput.allowFloats = false; m_pageInput.verticalAlignment = UIVerticalAlignment.Top; m_pageInput.padding.top = (int)((height - m_pageInput.font.size) / 2f); m_pageInput.submitOnFocusLost = true; m_pageInput.eventTextSubmitted += (x, y) => { if (int.TryParse(y, out int page)) { GoToPage(page); } else { m_pageInput.text = m_currentPage.ToString("0"); } }; KlyteMonoUtils.CreateUIElement(out m_totalPage, m_pagePanel.transform, "firstPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); m_totalPage.prefix = "/"; m_totalPage.verticalAlignment = UIVerticalAlignment.Middle; m_totalPage.minimumSize = new Vector2(m_pagePanel.width * .05f, height); KlyteMonoUtils.LimitWidthAndBox(m_totalPage, m_pagePanel.width * .05f); KlyteMonoUtils.CreateUIElement(out m_nextPage, m_pagePanel.transform, "nextPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); KlyteMonoUtils.InitButton(m_nextPage, false, "ButtonMenu"); m_nextPage.text = ">"; m_nextPage.eventClicked += (x, y) => GoToPage(m_currentPage + 1); KlyteMonoUtils.CreateUIElement(out m_lastPage, m_pagePanel.transform, "lastPage", new UnityEngine.Vector4(0, 0, m_pagePanel.width * .05f, height)); KlyteMonoUtils.InitButton(m_lastPage, false, "ButtonMenu"); m_lastPage.text = ">>"; m_lastPage.eventClicked += (x, y) => GoToPage(TotalPages); SetNewLength(0); GoToPage(1); }