Skip to content

[Solved][Unity] Resources.Load() Return Null

Last Updated on 2021-10-31 by Clay

In the past, I always used Resources.LoadAll<Sprite>() to create an Array<Sprite> object, but today, when trying to optimize the program, I tried to change to Resources.Load<Sprite>() to read a specific Sprite.

But since changing to this way of reading, the Sprite I read is cannot display any pictures; In other words, I use Resources.Load<Sprite>() return Null.

To confirm whether the Null is returned, just print it out.


Solution

Refer to the stackoverflow discussion at the bottom link, there are two solutions.


Method 1: Make sure that the path you put in the Resources folder is correct and that it is Sprite.

The folder name cannot be wrong at all. It should be noted that the Unity engine will not only look for the Resources folder under Assets, but also look for other folders to see if the Resources folder is included.


Method 2: Make sure you did not enter the file extension

For example, the picture name you originally entered is:

mySprite.png


It needs to be changed to:

mySprite

References


Read More

Tags:

Leave a Reply