- Home /
 
About Resources.Load

In yesterday my project Resource.Load can find file, but now cant find file
somebody can tell my why?...
Thanks!
 
                 
                resourcesload.jpg 
                (73.5 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by ShadoX · Jul 05, 2020 at 05:58 AM
According to the NullReferenceException it's not the file that can't be found but Image test, because you haven't created it. You can't assign something to the sprite variable on test if test itself doesn't exist , you need to do something like :
 test = gameObject.addComponent<Image>();
 
               for example
Answer by Elango · Jul 05, 2020 at 08:53 AM
"Image" is Unity UI class. You can't Resources.Load texture/sprite into it.
 Sprite image = Resources.Load<Sprite>(path);
 test.sprite = image;
 
               And make sure "test" is assigned in inspector.
Your answer