Asset Referencing

An "asset" in Unity is file in the Project window such as an AnimationClip, Texture, Prefab, or any script which inherits from ScriptableObject.

Approach Advantages Disadvantages
Serialized Fields
  • Very easy to use. Just add a serialized field to your script then drag and drop the asset you want into that field in the Inspector.
  • You can see which asset is being referenced just be looking at your script in the Inspector.
  • When your script is loaded it will automatically load all the assets it references as well.
  • Loading all the referenced assets immediately will cost some loading time and use additional memory even before those assets are actually used.
  • Only works on instance fields (not Static Fields or Properties) so every instance of a script will always have its own reference instead of being able to assign one asset for every instance to use.
Asset Injection
  • Used similar to Serialized Fields, but used for static fields (or properties) and instead of assigning the asset reference in the Inspector you assign it in the Injectors Panel in the Weaver Window.
  • Allows an asset to be assigned globally instead of having a separate reference for each instance of your script (basically, it avoids the disadvantages of Serialized Fields).
  • An asset assigned for injection will show an Overlay Icon in the Project window so that you know with a tooltip explaining exactly what it is linked to.
  • You can make it only load the asset when it is actually needed by using Asset<T> as the field type (see Injection Attribute Types for more information).
  • Requires you to purchase Weaver Pro (a plugin made by the author of this site). Weaver Lite does allow you to try out this feature in the Unity Editor though.
  • Only works on static fields and properties (just use Serialized Fields for instance fields).
Asset Lists
  • Allows you to create a list which will automatically contain all assets of a particular type in a target folder.
  • Requires you to purchase Weaver Pro (a plugin made by the author of this site). Weaver Lite does allow you to try out this feature in the Unity Editor though.
Resources
  • Fairly easy to use. Just put the asset in a folder called "Resources" and call Resources.Load when you want to load it.
  • You get to choose when to pay the performance cost of loading an asset.
  • Relies on hard coded resource path strings.
  • Nothing in the Unity Editor gives any indication that an asset will actually be loaded as a resource.
  • Everything in a "Resources" folder will always be included in a Runtime Build, even if there is no script that will ever load it, which will add unnecessary size to builds if you don't keep your project clean.
Asset Bundles
  • You get to choose when to pay the performance cost of loading an asset.
  • Reduces the initial download/install size of your application.
  • You can provide a different Asset Bundle for each platform containing assets which are designed and optimized specifically for that platform.
  • Can be used to implement downloadable content (DLC) and mods.
  • You need to manage distribution of the bundles in addition to the distribution of your actual project which makes them much more complicated to use than the alternatives listed above. This usually involves uploading the bundles to a server and implementing code in your project to download them.
Addressables
  • More complicated to learn than just using Asset Bundles directly (though the result is generally worth it).

Unity's Assets, Resources and AssetBundles tutorial explains how those systems work in more detail.