x


Creating a GameObject fails directly after Loading a Level

This behavior puzzled me quite a bit 'till I figured out what was happening, so I thought I'd document it in the hope of saving someone else the trouble of troubleshooting.

Here's the code I created that enabled me to isolate this issue - ObjectSpawner.js: It should spawn Temp1, Temp2, and Temp3 - but even though Temp2 seems to spawn correctly it never appears in Unity's scene hierarchy.

function Start () {

    var temp1 : GameObject = new GameObject("Temp1");

    DontDestroyOnLoad(this);
    DontDestroyOnLoad(temp1);
    Application.LoadLevel("Scene2");

    Temp2();

}

function Temp2 () {

    var temp2 : GameObject = new GameObject("Temp2");
    print(temp2.name); //It looks like it exists...

    Temp3();

}

function Temp3 () {

    yield;

    var temp3 : GameObject = new GameObject("Temp3");

}
more ▼

asked Jan 07 '12 at 04:19 AM

Aubrey Falconer gravatar image

Aubrey Falconer
672 46 54 68

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Question contains answer. If I should be posting questions I answer myself somewhere else, please let me know.

more ▼

answered Jan 07 '12 at 04:21 AM

Aubrey Falconer gravatar image

Aubrey Falconer
672 46 54 68

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2170
x268

asked: Jan 07 '12 at 04:19 AM

Seen: 304 times

Last Updated: Jan 07 '12 at 04:21 AM