SetActive/active/SetActiveRecursively 后两者比较旧,现在通常用第一个SetActive
必须先new一个gameobject对象用于实例化,然后再设置其active状态.不然会出错哦
GameObject gb; void Start() { gb = GameObject.FindGameObjectWithTag("Playbutton"); } void OnClick() { if (gb.active == true) { gb.SetActive(false); } else if (gb.active == false) { gb.SetActive(true); }
原文:http://www.cnblogs.com/TouchAfflatus/p/3536670.html