0
\$\begingroup\$

For example, I have a scene. The scene has a GameObject. The GameObject has reference to a prefab, like this:

class MyGameObject : MonoBehaviour { [SerializedField] private GameObject myPrefab; } 

And I assign a prefab to it in the inspector.

The prefab has references to some really huge resources, e.g. a MeshFilter with a hi-res mesh.

Now my question is: when is the mesh loaded? When I load the scene? Or when I instantiate the prefab for the first time? Also, is there a "resource loading debugger" where I can find out the answers myself?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

It's loaded when you load the scene, along with everything else in that scene or referenced by something in the scene (recursively). The scene will not finish loading and execute its first frame until all these dependencies have finished loading.

If you want to defer the loading of this asset to a later time, you can use Addressables to store an address of the prefab rather than a direct reference. Then in script you can choose when to load the asset at that address, and can do so asynchronously while the scene runs.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.