Finding a gameobject in a level that has not been loaded

I’m planning to show end-screen after player has played a level. In this endscreen I display text using 3dText. What I’m now trying is to change the text before I use loadlevel so that it would be ready when the endscreen is shown. I know that changing this text is fast and this I could do after loading a level, but I’m wondering if the same solution could be used in general. I might have situation when initializing other objects might take a bit longer.

So the actual problem comes when I try to use gameobject.find to find a 3Dtext object. This returns null if the level has not been loaded yet. Is it even possible to find a gameobject on a level that has not been loaded? Or is there another way of initializing 3dText so I would not need to use a find? Or would you recommend completely another kind of design?

It is not possible to perform a Find operation on a gameobject which is not loaded.

You have a few options:

  1. Have the 3DText loaded in your first scene (but out of view) and use DontDestroyOnLoad to stop it from being deleted when the scene loads. Then move it when the endscreen scene is loaded.
  2. I’m guessing the endscreen 3DText is dependant on some variable in the previous scene. Use DontDestroyOnLoad to make sure the gameobject containing the variable is not deleted when the scene changes. Then in the Awake function of your 3DText read the variable.

There are other ways but those seem the most straight-forward.