private void _removePageContainer(GameObject pageContainer) { PageViewPageContainer pageComponent = pageContainer.GetComponent <PageViewPageContainer> (); pageComponent.pageView = null; pageComponent.content = null; pageContainer.transform.SetParent(null); pageContainer.transform.DetachChildren(); }
private GameObject _createPageContainer() { GameObject pageContainer = Instantiate(this.pageContainerPrefab); PageViewPageContainer pageComponent = pageContainer.GetComponent <PageViewPageContainer> (); pageContainer.transform.SetParent(this._contentPanel.transform); pageComponent.pageView = this.gameObject; return(pageContainer); }
private void _updatePages() { if (this._pageContents.Count < this._contentPanel.transform.childCount) { while (true) { GameObject pageContainer = this._contentPanel.transform.GetChild(this._pageContents.Count).gameObject; if (pageContainer) { this._removePageContainer(pageContainer); } else { break; } } } else { while (this._pageContents.Count > this._contentPanel.transform.childCount) { this._createPageContainer(); } } for (int pageIndex = 0; pageIndex < this._pageContents.Count; pageIndex++) { GameObject pageContainer = this._contentPanel.transform.GetChild(pageIndex).gameObject; PageViewPageContainer pageComponent = pageContainer.GetComponent <PageViewPageContainer> (); pageContainer.transform.DetachChildren(); this._pageContents [pageIndex].transform.SetParent(pageContainer.transform); pageComponent.pageIndex = pageIndex; pageComponent.content = this._pageContents[pageIndex]; } if (this._pageContents.Count > 0 && this._pageIndex >= this._pageContents.Count) { this.JumpToPage(this._pageContents.Count - 1); } }