unity3d - Why does Resources.Load <Sprite> return null? -
There are several spirits in my project which are located in Assets \ Sprats, which I want to load using the C # script .
I tested it:
Sprite myFruit = Resources.Load & lt; Sprite & gt; ("Graphics_3");
but myFruit
is still empty.
resources.Load
property / resources
Will search a directory.
If you want to put it in the Sprites
directory, then it is the resource
(e.g., Property / Resources / Sprite
).
Then you can load it like this:
Sprite myFruit = Resources.Load & lt; Sprite & gt; ("Sprites / Graphics_3");
Also make sure that you have set your image type Sprite in Inspector.
If you want to load multiple sprites, then use it:
Sprite [] myFruit = Resources.LoadAll & lt; Sprite & gt; ("Sprites / Graphics_3");
See for more information.
Comments
Post a Comment