How does Unity work under the hood, and which of these is 1. faster, and 2. lower in resource use?
The first is to use Resource.Load every time I want to grab a prefab, texture, etc.
The second is to have a Monobehaviour on a GameObject that I can drag/drop prefabs, textures, and the like in to the inspector fields as a reference.
Is Unity loading these references into memory behind the scenes, or just when needed. What’s going on?
As a general rule only use resources when you have no other choice.
– KiwasiSo the best thing to do would be to create a new GameObject in the hierarchy and attach a script that has all the references in it. Rather than loading everything with resources.load at the start of the scene?
– Whippetsyes, until you need logic to decide which asset to use.
– smoggachSo, does using references actually keep the referenced items in memory, so there's no loading - or does it just make that loading quicker?
– WhippetsIt doesn't keep them in memory. Where the run time efficiency comes in is not having to search the resources folder to find the appropriate asset. There are also efficiencies to work flow and file size.
– Kiwasi