I’ve went several times through this Unity Manual it’s always missing as GameObject on end and even if I correct that error it always thinks my instance is Null how do I instantiate a Prefab? so I don’t need to duplicate every prefab?
what I want to achive is: Prefab in instantiated Object and not GameObject as him self
GameObject instance = Instantiate(Resources.Load("Hatchet"));
GameObject instance = Instantiate(Resources.Load("Hatchet", typeof(GameObject))) as GameObject;
ArgumentException: The thing you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:71)
UnityEngine.Object.Instantiate (UnityEngine.Object original) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:58)
Inventory.Start () (at Assets/Player/Inventory.cs:38)
Hi sorry for asking can u solve my problem , i think almost same problem as him, this is the error code
ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:381)
UnityEngine.Object.Instantiate (UnityEngine.Object original) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:240)
Sample.ImageTarget_DynamicLoad_ManualPlay.LoadVideo () (at Assets/EasyAR/Scripts/ImageTarget_DynamicLoad_ManualPlay.cs:40)
Sample.ImageTarget_DynamicLoad_ManualPlay.Start () (at Assets/EasyAR/Scripts/ImageTarget_DynamicLoad_ManualPlay.cs:35)
The code on the line are respectively:
cs 35 . LoadVideo()
cs 40 . GameObject subGameObject = Instantiate(Resources.Load(“TransparentVideo”, typeof(GameObject))) as GameObject;
Try to preload the prefab before you instantiate it. You can use Start() method.
GameObject _go;
void Start()
{
// Make sure that you put your prefab in the folder Assets/Resources
_go = Resources.Load("MyPrefab") as GameObject;
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(_go, transform.position + Vector3.up, Quaternion.identity);
}
}