Answer the question
In order to leave comments, you need to log in
Why is the sprite not being loaded by the Resources.Load method?
The question is this - I have a sprite, I declared it as hero2, and in void Start I assigned it a picture from the folder
Sprite hero1;
Sprite hero2;
void Start () {
hero1 = sr.sprite;
hero2 = Resources.Load<Sprite> ("back.png");
}
Answer the question
In order to leave comments, you need to log in
Read at least a little documentation...
The sprite should be in the "Resources" folder, i.e. the full path to it should be "Assets/Resources/back.png" then it will load.
First, make sure the sprite is in the resources folder, Resources.Load loads the relative path from all folders in the project called Resources. Secondly, when loading from resources, you do not need to specify the extension. Thirdly, there is a possibility that you are loading by the wrong name, back is the name of the texture, the sprite can be called back_0 or something, check.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question