资源加载的问题
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)