//Note: This comes after smenu sets the widget positions. public void InitStringWidget() { background.renderer.enabled = false; smenu = (SentenceMenu)menu; ErrorHandler(); Resize(); //Shift the widgets down correspondingly to the number of indices. float shift_down = ((choices.Length-1) / 2.0f) * smenu.widget_height; transform.position += new Vector3(0f,-shift_down,0f); //Handle global y-positioning of the choices text in the widget Vector3 pos = new Vector3(transform.position.x,smenu.GetTranslatedY(),-0.1f); for(int i=0;i<choices.Length;i++) { //transform.position = pos; //transform.localPosition = new Vector3(transform.localPosition.x,transform.localPosition.y,-0.1f); TextMesh added = Instantiate(((SentenceMenu)smenu).textPrefab,pos,Quaternion.identity) as TextMesh; added.transform.parent = gameObject.transform; added.text = choices[i]; GUI_choices.Add(added); pos.y -= (smenu.row_dist + smenu.choice_height); } move_dist = smenu.choice_height + smenu.row_dist; //Set the indices and default starting y position index = (choices.Length - 1) / 2; if(index < 0) index = 0; if(index > choices.Length) index = choices.Length; transform.position += new Vector3(0f,move_dist*index,0f); }