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.
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.
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.