public void Awake() { BindControls(); m_properties = m_mainPanel.GetComponent <BindPropertyByKey>(); #region Events bindings BindEvents(); KlyteMonoUtils.LimitWidthAndBox(m_title, out UIPanel boxContainerTitle); boxContainerTitle.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top; boxContainerTitle.relativePosition = new Vector3(0, 2); //This action allow centralize all calls to single object, coming from any mod m_mainPanel.objectUserData = new Action <Dictionary <string, object>, Func <int, bool> >((Dictionary <string, object> properties, Func <int, bool> callback) => StartCoroutine(Enqueue(BindProperties.FromDictionary(properties), callback))); m_mainPanel.stringUserData = VERSION; m_closeButton.eventClicked += (x, y) => Close(0); m_mainPanel.enabled = true; #endregion }
public void Awake() { m_mainPanel = GetComponent <UIPanel>(); m_titleContainer = m_mainPanel.Find <UIPanel>("TitleContainer"); m_title = m_titleContainer.Find <UILabel>("Title"); m_modIcon = m_titleContainer.Find <UISprite>("ModIcon"); m_closeButton = m_titleContainer.Find <UIButton>("CloseButton"); m_boxText = m_mainPanel.Find <UILabel>("BoxText"); m_buttonSupContainer = m_mainPanel.Find <UIPanel>("ButtonSupContainer"); m_button1 = m_mainPanel.Find <UIButton>("ButtonAction1"); m_button2 = m_mainPanel.Find <UIButton>("ButtonAction2"); m_button3 = m_mainPanel.Find <UIButton>("ButtonAction3"); m_button4 = m_mainPanel.Find <UIButton>("ButtonAction4"); m_button5 = m_mainPanel.Find <UIButton>("ButtonAction5"); m_textField = m_mainPanel.Find <UITextField>(TEXT_INPUT_ID); m_textureSupContainer = m_mainPanel.Find <UIPanel>("TextureSupContainer"); m_textureSprite = m_mainPanel.Find <UITextureSprite>("TextureSprite"); m_properties = m_mainPanel.GetComponent <BindPropertyByKey>(); #region Events bindings m_mainPanel.enabled = false; m_button1.eventClicked += (x, y) => OnButton1(); m_button2.eventClicked += (x, y) => OnButton2(); m_button3.eventClicked += (x, y) => OnButton3(); m_button4.eventClicked += (x, y) => OnButton4(); m_button5.eventClicked += (x, y) => OnButton5(); KlyteMonoUtils.LimitWidthAndBox(m_title, out UIPanel boxContainerTitle); boxContainerTitle.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top; boxContainerTitle.relativePosition = new Vector3(0, 2); //This action allow centralize all calls to single object, coming from any mod m_mainPanel.objectUserData = new Action <Dictionary <string, object>, Func <int, bool> >((Dictionary <string, object> properties, Func <int, bool> callback) => StartCoroutine(Enqueue(BindProperties.FromDictionary(properties), callback))); m_mainPanel.stringUserData = VERSION; m_closeButton.eventClicked += (x, y) => Close(0); m_mainPanel.enabled = true; #endregion }
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); }