Hope someone can help with this. I have a prefab called ‘brick’ (it’s just a red cube).
This prefab is in a folder called ‘prefabs’ inside my assets folder. It’s not in the scene.
In javascript, I’m trying to instantiate the prefab using:
var brick : Transform;
function Start () {
var y = 0;
var x = 0;
Instantiate(brick, Vector3 (x, y, 0), Quaternion.identity);
}
}
}
But I get the error:
ArgumentException: The prefab you want to instantiate is null.
What does this mean? – I wish Unity’s errors were more n00b-friendly!
Brilliant, thank you ARKMs. Works like a charm. I’m using
var instance : GameObject = Instantiate(Resources.Load(myLitem, GameObject));
Where myLitem is the GameObject I used using the GameObject.find earlier up in the script.
One question: Although this works well, the instantiated object always appears at the x y z co-ordinates of 0. One thing I couldn’t work out was how would you get the instantiated object to appear at the location of a GameObject? @ARKMs