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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -