- Home /
Resource.Load v Inspector object reference
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?
Answer by smoggach · Oct 01, 2014 at 01:32 PM
Generally speaking it's faster to use references. However loading things yourself with resources or streamingassets gives you a lot more flexibility. For instance if you want to support both high and low resolutions you'll need to wait until the program is launched to figure out whether to use a high res or low res image.
As a general rule only use resources when you have no other choice.
So 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?
So, does using references actually keep the referenced items in memory, so there's no loading - or does it just make that loading quicker?
It 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.
Your answer
Follow this Question
Related Questions
Inspector scene and hierarchy views all grayed out in play mode. 0 Answers
How to auto-navigate project hierarchy to asset by clicking in inspector? (Doesn't work anymore.) 1 Answer
have i derive from MonoBehaviour to expose fields in inspector? 0 Answers
Display Non Monobehaviour array in inspector C# 1 Answer
Is there a way to extend the amount of values for inspector? 0 Answers