- Home /
How to GUI texture image change?
GUI Button in texture image mapping, on button clicked, want texture image change....
how to GUi texture image change?
Comment
Create GUI Skin and change its attributes.There are many attributes you will find easy to use.Use the skin in your script. Wlink textW
Best Answer
Answer by moghes · Feb 19, 2013 at 08:53 AM
Dude, changing the texture of a guitexture is a simple process, you can do it either with a GUI Skin as suggested by PushpaK , or check this example.. it might help you.. just comment if anything is not clear about the code
public var yourGUITexture:GUITexture;
public var texture1:Texture2D;
public var texture2:Texture2D;
private var yourCurrentTexture:Texture2D;
private var showAlert = false;
// whenever you will show the window just set showAlert = true;
function OnGUI()
{
if(showAlert)
var window = GUI.Window(0 , Rect(posX,posY,someWidth,someHeight), ShowAlert ,"");
yourGUITexture.texture = yourCurrentTexture;
}
function ShowAlert(windowID : int)
{
if (GUI.Button (Rect(posX,posY,someWidth,someHeight), "LeftButton"))
{
showAlert= false;
yourCurrentTexture = texture1;
}
if (GUI.Button (Rect(posX*2,posY,someWidth,someHeight), "RightButton"))
{
showAlert= false;
yourCurrentTexture = texture2;
}
}
Your answer
Follow this Question
Related Questions
Apply Render Texture To GUI + Transparency? 2 Answers
GuiTexture (Touch button) unfollow camera! 1 Answer
GUITexture Button? 1 Answer
rotating GUI texture by angle 2 Answers
Sprites and minmizing memory usage 1 Answer