NullReferenceException - strange problem instantiating prefab

I’m not sure if I’ve lost my mind and I’m doing something stupid that I’m just not seeing but here is the problem. I started having trouble with this bug in my game and decided to start a new project with just the barebones setup needed to reproduce it.

All I’m doing is very simple.

  1. Imported mesh.
  2. Created prefab “testPrefab” of mesh.
  3. Created “Game” empty gameobject in Hierarchy.
  4. Created “Game.js” script and attached it to “Game” object in Hierarchy.
var test : Transform;

function Start()
{
	print("test = " + test);
	Instantiate(test, Vector3(0,0,0), Quaternion.Identity);
}

I’ve assigned the “test” prefab to the target variable exposed in “Game”.

In the console the print function prints this

test = testPrefab (UnityEngine.Transform)
UnityEngine.MonoBehaviour:print(Object)
Game:Start() (at Assets/Game.js:5)

Everything seems fine there, I think, it sees it right ?!?!? But then I get

NullReferenceException: Object reference not set to an instance of an object
Game.Start () (at Assets/Game.js:6)

I assume I’m making some silly blunder but, I’ve been doing things similar to this for months now without trouble, I just don’t understand.

I’ve tried restarting Unity, rebooting computer, completely new project, importing a different mesh… I don’t know, any ideas?

Sigh, a silly mistake… Quaternion.identity, not Quaternion.Identity… wish the compiler error said “hey I don’t know what Quaternion.Identity is”.

Use C# and Visual Studio’s intellisense and you’ll never have a problem like that again.