// Use this for initialization void Start() { //Store the initial number of page lastTimePage = this.transform.GetChild(0).childCount; //The first calculate of the page offset for (float i = 0; i < lastTimePage; i++) { float temp = i / (lastTimePage - 1); pages.Add(temp); } //At the begining, the index is always 0. toggle.PageChanged(lastTimePage, 0); //Get the ScrollRect Component rect = GetComponent <ScrollRect>(); }