2
出於某種原因,我得到它看起來像這樣的錯誤:Unity2D:UnassignedReferenceException:變量尚未分配實例化
UnassignedReferenceException: The variable LevelComplete of NPad1 has not been assigned.
,這是我的代碼:
public class NPad1 : MonoBehaviour {
public Sprite img1 , img2;
public Rigidbody2D LevelComplete;
void Start() {
gameObject.GetComponent<SpriteRenderer>().sprite = img1;
}
// Update is called once per frame
void OnTriggerEnter2D(Collider2D other) {
gameObject.GetComponent<SpriteRenderer>().sprite = img2;
Instantiate (LevelComplete);
}
我做了什麼錯?
是的,你是對的,我把這段代碼放在我的對象上而不是我的預製件上,非常感謝! – 2014-12-06 19:28:24