Hello all
So I want to load different textures for my game object when different conditions are met. Below is a snippet of one of the conditions:
if ((amount > 151f) && (amount < 200f))
{
Material.color = Color.blue;
Renderer rend = GetComponent();
rend.material.mainTexture = Resources.Load(“face2”) as Texture;
}
This does not work and I do not understand why.
Please assist; I am so frustrated with this right now
Resources.Load looks at resources in the Resources folder. If your resource is in a subfolder, you should add the relative path. For example, if your face2 is located at Resources/charcaters/faces/face2, you should use Resources.Load(“characters/faces/face2”).
@madks13
Thank you for your reply.
I just checked again to make sure and there are no subfolders in the resources folder
Not sure why this code isn’t working
This seems to work:
if ((amount > 151f) && (amount < 200f))
{
Renderer _rend = GetComponent<Renderer>();
Material _mat = _rend.material;
_rend.material.mainTexture = Resources.Load("face2") as Texture;
_mat.color = Color.blue;
}