Instantiate in Unity 5

I use the following code to spawn some Objects in my project:

if (s == side && filled == false)
{
var n : GameObject;
n = Instantiate (GameObject.Find(“GameMaster”).GetComponent(GameMaster).selectedTile, transform.position, Quaternion.identity);
n.transform.parent = GameObject.Find(“Ghosts”).transform;
n.transform.eulerAngles = transform.eulerAngles;
n.GetComponent(Wall).giveSegment(gameObject);
Debug.Log(transform.rotation);

}

In Unity 4, this worked perfectly fine but since converting to Unity 5 there is a problem. It still spawns the object, but doesn’t spawn its child objects, like the 3d model. If I just drag the prefab into the scene it works, it just seems like the instantiate is broken somehow.

Instead of using GameObject.Find(); it’s much easier to make a public variable for the object that you want to instantiate.

var objectToInstantiate : GameObject;

if(event){
   var instantiatedObject = Instantiate(objectToInstantiate, position, rotation);
}

If you want to add the new object you instantiate to a variable, just declare the variable and set it to the Instantiate() function right away.