I’m trying to load a sprite to my Ui.Image but for some reason i’m not getting any errors or results. I’m not sure how to debug this issue.
public GameObject DisplayImage;
void OnClick( int id ){
DisplayImage.GetComponent<Image>().sprite = Resources.Load("Assets/CharacterImages" + results[id].ImgName) as Sprite; //results[id].ImgName = "/Humans/Soldier"
}
I’m not sure what path works so i’ve tried the following already and none of them work.
- Assets/CharacterImages/Humans/Soldier
- …/CharacterImages/Humans/Soldier
- /CharacterImages/Humans/Soldier
- CharacterImages/Humans/Soldier
Appreciate it if anyone can point me in the direction to figure this out. Thanks.
Unity is not letting me create a Resource folder outside of Assets. so the full path would be Assets/Resources/CharacterImages/Humans/Soldier but Resources.Load only requires "/CharacterImages/Humans/Soldier"?
– GrandmasterHThat is correct. Resources folders can be anywhere in the assets folder. When you use Resources.Load, you do NOT use the path of the object; instead, you only use the file name of the asset without extensions. See the code I posted in my answer.
– RLinare you a bot? you have posted this response to several messages...
– mattburnett