Changing material (not texture)

Hi! I have this game component called “gui_Stage01” (it’s not a gui texture, don’t ask) and it has a child called “BossSelectFrame01”.

What I want to do is to change the material of the child on mouse entry.
This is what I got:

void OnMouseEnter()
{
    if (gameObject.name == "gui_Stage01")
    {
        audio.Play();
        transform.FindChild("BossSelectFrame01").renderer.material.name = "mat_BossFrameOn";
    }
}

However, that only changes the name of the material, not the material itself.
Can someone please help me :slight_smile:

You need to change the material, not the name:

public Material matBossFrameOn; // assign this in your inspector
void OnMouseEnter()
{
    if (gameObject.name == "gui_Stage01")
    {
        audio.Play();
        transform.FindChild("BossSelectFrame01").renderer.material = matBossFrameOn;
    }
}