public void Setup(int iPages, int iCurrentPage) { if (this.pageCount == iPages && this.pageCurrent == iCurrentPage) { return; } this.pageCount = iPages; this.pageCurrent = iCurrentPage; dfControl[] componentsInChildren = base.gameObject.GetComponentsInChildren <dfControl>(); for (int i = 0; i < (int)componentsInChildren.Length; i++) { dfControl _dfControl = componentsInChildren[i]; if (_dfControl.gameObject != base.gameObject) { UnityEngine.Object.Destroy(_dfControl.gameObject); } } if (this.pageCount <= 1) { return; } dfControl component = base.GetComponent <dfControl>(); bool flag = true; Vector3 vector3 = new Vector3(0f, 0f, 0f); for (int j = 0; j < this.pageCount; j++) { if (this.buttonGroups - j > 0 || j >= this.pageCount - this.buttonGroups || Math.Abs(j - this.pageCurrent) <= this.buttonGroups / 2) { dfButton str = ((GameObject)UnityEngine.Object.Instantiate(this.clickableButton)).GetComponent <dfButton>(); component.AddControl(str); str.Tooltip = j.ToString(); str.MouseDown += new MouseEventHandler(this.OnButtonClicked); str.Text = (j + 1).ToString(); str.Invalidate(); if (j == this.pageCurrent) { str.Disable(); } str.Position = vector3; vector3.x = vector3.x + (str.Width + 5f); flag = true; } else { if (flag) { this.DropSpacer(ref vector3); } flag = false; } } component.Width = vector3.x; }
public void Setup(int iPages, int iCurrentPage) { if ((this.pageCount != iPages) || (this.pageCurrent != iCurrentPage)) { this.pageCount = iPages; this.pageCurrent = iCurrentPage; foreach (dfControl control in base.gameObject.GetComponentsInChildren <dfControl>()) { if (control.gameObject != base.gameObject) { Object.Destroy(control.gameObject); } } if (this.pageCount > 1) { dfControl component = base.GetComponent <dfControl>(); bool flag = true; Vector3 vPos = new Vector3(0f, 0f, 0f); for (int i = 0; i < this.pageCount; i++) { if ((((this.buttonGroups - i) <= 0) && (i < (this.pageCount - this.buttonGroups))) && (Math.Abs((int)(i - this.pageCurrent)) > (this.buttonGroups / 2))) { if (flag) { this.DropSpacer(ref vPos); } flag = false; } else { dfButton child = ((GameObject)Object.Instantiate(this.clickableButton)).GetComponent <dfButton>(); component.AddControl(child); child.Tooltip = i.ToString(); child.MouseDown += new MouseEventHandler(this.OnButtonClicked); child.Text = (i + 1).ToString(); child.Invalidate(); if (i == this.pageCurrent) { child.Disable(); } child.Position = vPos; vPos.x += child.Width + 5f; flag = true; } } component.Width = vPos.x; } } }