- Home /
Question by
shivansh11 · Jan 02, 2017 at 04:45 PM ·
javascriptsprite
Resources.Load(filename) as Sprite is returning null
The path-name is correct.
public var pic : Sprite;
function Start(){
pic = Resources.Load("Targets/1") as Sprite; //pic becomes null
}
Comment
Answer by Or-Aviram · Jan 02, 2017 at 05:17 PM
Try using the generic overload: Resources.Load<Sprite>("name")
Answer by tanoshimi · Jan 02, 2017 at 05:13 PM
"1" is not a very descriptive filename; If I had to take a shot in the dark, do you happen to have two resources with the same name but different extensions? (a "1.png" and a "1.prefab", for example?) - Resources.Load won't know which to pick and so will return null in that case. I'd recommend you give your resources more descriptive names.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Flipping a 2D Sprite in Javascript 0 Answers
How do I animate a 2D sprite? 1 Answer
How to load sprites into array Sprite[] in Javascript 2 Answers