为了账号安全,请及时绑定邮箱和手机立即绑定

资源加载的问题

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class tank : MonoBehaviour {
    private GameObject Bullet;
    private GameObject bullet;
	// Use this for initialization
	void Start () {
        Bullet = Resources.Load("Bullet") as GameObject;
    }
	
	// Update is called once per frame
	void Update () {
		if(Input.GetButtonDown("Fire1"))
        {
            bullet = Instantiate(Bullet);
            bullet.transform.parent = this.transform;
        }
	}
}

28分钟左右的地方在讲资源加载,按照老师的操作来的,但是运行起来报错

ArgumentException: The Object you want to instantiate is null.

UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:239)

UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:200)

tank.Update () (at Assets/Scripts/tank.cs:17)


正在回答

5 回答

是不是没把需要加载的预设物,放进Resources文件夹里

0 回复 有任何疑惑可以回复我~

会不会是名字不区分大小写

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

资源加载的问题

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信