Unity Editor Script Troubles

Hey guys,

I’m having lots of troubles getting objects to instance in an editor script. Is there some rule I’m not aware of? Here’s my code.

Debug.Log(child.name); //This is just to test that the Game Object is valid. Which it is.

var newChild:GameObject = Instantiate(child,child.transform.position,child.transform.rotation) as GameObject;

It crashes on the second part claiming that "Object reference not set to an instance of an object. Anyone know what’s going wrong here?

Got it working.

I guess you can’t use the “:GameObject” in the declaration. And the “as GameObject” at the end isn’t needed.