- Home /
GameObject.Find() in additively loaded scenes?
I load a scene at runtime additively with LoadLevelAdditiveAsync. Looks like if - from the level of first scene object - I were unable to access additively loaded scene objects - with use of:
GameObject.FindGameObjectsWithTag();
GameObject.Find();
FindObjectOfType(typeof(Type));
and the likes. Has anyone also experienced this?
So I went the other way round: - accessing 1st scene objects from additive scene objects.
Answer by Tehnique · Jul 09, 2014 at 11:28 AM
Are you sure you wait until the new Scene is loaded? Maybe call yield after you load the level so it waits for the result, and search afterwards.
I wouldn't ask before trying this. I've put a number of yiedls
yield return new WaitForFixedUpdate ();
after Application.LoadLevelAdditiveAsync. That's not an answer.
agreed; make sure you do a yield return xxx;
after the load request and set a flag to check elsewhere before anything is accessed. i.e.
var loaded = false;
var loadedLevel = Application.LoadLevelAdditiveAsync("$$anonymous$$yLevel");
yield return loadedLevel;
loaded = true;
make sure this is done somewhere where you can yield (`IEnumerator`)
then just check loaded == true
before accessing loadedLevel
- i.e.
if (loaded)
{
...
}
But do you actually yield for the result of the LoadLevelAdditiveAsync operation? Because from what I see, you just wait for the next frame. Next frame can come immediately, but the result of the load comes later.
When done in accordance with the below scripting API example - all works.
AsyncOperation async = Application.LoadLevelAdditiveAsync("$$anonymous$$yAddLevel");
yield return async;
Your answer
![](https://koobas.hobune.stream/wayback/20220613153605im_/https://answers.unity.com/themes/thub/images/avi.jpg)