- Home /
Question by
sanamdehghan · Dec 26, 2011 at 10:22 PM ·
texturebuttonmute
Change the texture of mute button
I want to make a mute button for my HUD. so I made 2 textures for mute button, that one shows that the music is playing and the other one shows the music is not playing. So how can I change the texture of a button when the player click it?
Thanks for your helps in advanced
Comment
Answer by Rod-Green · Dec 27, 2011 at 01:26 AM
Just set the GUITexture.texture value to the texture you want it to be.. i.e.
public GUITexture m_targetGUITexture;
public Texture m_mutedTexture;
public Texture m_unmutedTexture;
bool m_wasHit;
bool m_muted;
void OnGUI()
{
if(m_wasHit)
{
m_muted = !m_muted;
if(m_muted)
m_targetGUITexture.texture = m_mutedTexture;
else
m_targetGUITexture.texture = m_unmutedTexture;
}
}
Your answer
Follow this Question
Related Questions
Toggle button GUI texture not changing on click? 0 Answers
Mute Unity Ads in code? 2 Answers
Normal map strange shading lines. 0 Answers
why is my extract textures button can't click on it? 0 Answers