Accelerate Video Game Development

How to use Unity's Resources

Leszek Król

Unity has preserved some special names for folders like: Assets, Editor, Streaming Assets and Resources. Today we are going to talk about the last one.

Resources folder

Unity allows developers to store Assets within one or more folders named Resources. Those assets can be loaded or unloaded at runtime using the Resources API.

Resources folder

For load assets purpose you can use Resources.Load method. It have 2 parameters:

  • path - a path to loaded file. When you pass empty string as argument, this method will load entire contents of the Resources folder.
  • systemTypeInstance - optional parameter. Type filter for objects returned.

The path is relative to any Resources folder inside the Assets folder of your project. So when you have structure Assets/RobotsAssets/Resources/head.jpg for example, your path should look like that: Resources.Load("head").

Important! - Do not include the file extension names (.txt, .jpg, .fbx) in the path parameter.

This post is for paying subscribers only

Sign up now and upgrade your account to read the post and get access to the full library of posts for paying subscribers only.

Sign up now Already have an account? Sign in
Your link has expired
Success! Check your email for magic link to sign-in.
Please enter at least 3 characters 0 Results for your search

May we suggest an author?

Leszek Król