- Home /
Gui Texture Swap?
I made a menu for a small Unity game but I have a small something I would like to add, The problem is I don't know how to. Basically what I want to achieve is to have buttons on my score history page in the menu that will change the texture of the page itsself, this because we have 4 tracks (yes its a race game) and I don't want to have to make 4 score history levels. So is there someone who can help me to do this?
Answer by equalsequals · Jun 03, 2010 at 02:04 PM
The simple way to implement this is to create a public reference to a Texture2D and assign it the texture you want in the Inspector. From there when you want to change your texture you just have a reference to the GUITexture you want to swap textures of and assign the new texture using this:
myGUITexture.texture = myNewTexture2D;
Cheers,
==
Great, I'll be sure to try it today, Btw do I need to change ''myNewTexture2D'' into the name of the particular texture? Since else how will unity know what texture to change in?
Thanks for helping this will make my menu look even better.
I am not really good at scripting so hoping you can help me with this one. Error: BCE0005: $$anonymous$$ identifier: 'myGUITexture'.
"myGUITexture" is a variable you would create. Try adding the line public var myGUITexture:GUITexture in your javascript class and then through your Inspector assign the GUITexture you want to be able to swap.
Your answer
Follow this Question
Related Questions
GUITexture scaling with aspect ratio? 1 Answer
GUI texture touch input problem 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Activating GUI 2 Answers
Render GUI with Material 1 Answer