Hi, so im trying im making a GUI by hand (as in not using unity’s built in GUI system) and I’m changing the sprite renderer’s sprite on this empty object every time the player clicks something. I want to know if there’s a way to check for a gameobject’s sprite name? I want to check if the gameobject is using the sprite that I specifically write out I mean.
if (Input.GetKeyDown(KeyCode.Z))
{
if (spikedskinZEquip == false)
{
TurnAllZSlotsOff();
spikedskinZEquip = true;
spikedskinXEquip = false;
spikedskinCEquip = false;
ZitemIcon.GetComponent<SpriteRenderer>().sprite
= Resources.Load("SpikySkin", typeof(Sprite)) as Sprite;
////if(XitemIcon.renderer. == "SpikySkin")
XitemIcon.GetComponent<SpriteRenderer>().sprite
= Resources.Load("", typeof(Sprite)) as Sprite;
////if(CitemIcon.renderer.material.name == "SpikySkin")
CitemIcon.GetComponent<SpriteRenderer>().sprite
= Resources.Load("", typeof(Sprite)) as Sprite;
}
}
You see those parts where I put “////” I want to try and check for the name of the sprite of these gameobjects, and if the name is the same, I want to change the attached sprite, as shown. Does anyone know to accomplish that…? I tried using renderer.name and material.name… but they aren’t it. The only other way I could think of accomplishing this is by using tags.