我正在尝试创建一个脚本,该脚本对您收集的对象进行计数并将其显示在对象中。
到目前为止,这里有我的脚本。
import UnityEngine.UI;
var Paper : int = 0;
var paperToWin : int = 30; //number to win!
var countText : GameObject;
function OnTriggerEnter( other : Collider )
{
if (other.gameObject.tag == "Paper")
{
Paper += 1;
Debug.Log("A paper was picked up. Total papers = " + Paper);
Destroy(other.gameObject);
}
}
function Update() {
countText.text = Paper.ToString;
}
如果有人可以帮助,那就太好了。