My project has multiple sprites located in Assets\Sprites which I want to load using C# script.
I have tested this:
Sprite myFruit = Resources.Load <Sprite> ("Graphics_3");
But myFruit
is still null.
Resources.Load
will search for a directory in Assets/Resources
.
If you want to put it to Sprites
directory then put it inside Resources
(ex. Assets/Resources/Sprites
).
Then you can just load it like this:
Sprite myFruit = Resources.Load <Sprite> ("Sprites/Graphics_3");
Also make sure that you've set your image type to Sprite in the inspector.
If you want to load multiple sprites, use this:
Sprite[] myFruit = Resources.LoadAll <Sprite> ("Sprites/Graphics_3");
See this for more details.