琢磨了一天之后,终于搞定了,动态实例化按钮,代码如下:
GButton btnLeagueList;
GameObject family_task;
family_task = Instantiate(btnLeagueList.gameObject) as GameObject; btnLeagueList.Text = "门派任务"; if (family_task != null) { family_task.transform.parent = transform; family_task.transform.localScale = new Vector3(1, 1, 1); family_task.transform.localPosition = new Vector3(218, -230, 0); } thisCtrl = this; Debug.Log(123);
注意: 脚本在实例化的时候,实例化对象必须是gameObject
;
网友评论