Does putting prefab asset in inspector's reference and access its content inside in runtime VS. Load the same prefab asset from
Resources.Load API, will both cause entire prefab to load and use same memory footprint?
In UNET or it's replacement lib, Mirror, you will have to register list of prefab on NetworkManager to spawn on server and clients.
Under the hood, these prefab references will be sent to registration function
ClientScene.RegisterPrefab which in turn access them as far as
(I suspect that this will make entire prefab loaded?)
I put those prefab in Resource folder, then use API like
Resources.Load / LoadAll to send them to
ClientScene.RegisterPrefab (which proved to work too) But many fellow dev warned me about how evil
Resources API is and using these will load all data into memory, etc.
Didn't this 2 way ultimately need to access inside of prefab and both need to load entire prefab in? Is there clear advantage for memory footprint for approach?
Some prior research
In official document about resource management, there is some explanation about how resource will load but it still does not clear up difference between these 2 appraoches.
2.7. Resource lifecycle
To reduce loading times and manage an application's memory footprint, it's important to understand the resource lifecycle of UnityEngine.Objects. Objects are loaded into/unloaded from memory at specific and defined times. An Object is loaded automatically when:
- The Instance ID mapped to that Object is dereferenced
Foot note/ Some clarification
Why do you need to use Resources.Load?
Take UNET example case here in my question, and notice that it needs to know every prefab that will be use in game, that's including monsters, items, bullet. Sure you can drag and drop these to inspector (like in screenshot) but will become tedious and unorganized very fast on magnitude of 50+ prefabs. So instead I organize them to Resources folder like
Assets/Resources/EnemyPrefab/Stage1/*.* Assets/Resources/EnemyPrefab/Stage2/*.* Assets/Resources/ItemPrefab/*.*
To get more organized load pattern.
Resources.LoadAll<GameObject>("EnemyPrefab/Stage1") will do as it suggest. And skipping tedious inspector drag and drop work, let alone checking what did I missed to drag and drop.
Can't you just profile it yourself? why asking here?
I could, but if someone already done this work or has knowledge to confirm such behavior, this could be better, thus this question here. And hey, didn't this is how knowledge is shared and this site is for?