Hi Forum
I’m trying to build a custom button for my Game GUI…
I’m using this code:
public var icon : Texture2D;
function OnGUI () {
if (GUI.Button (Rect (10,10, 100, 50), icon)) {
print ("you clicked the icon");
}
}
I set the icon-var in the inspector to a texture in my project…
But when I start the game, all I get is the old black standard-button…
Why???
OK, got it - I set the texture in the wrong script… oh my…
I would highly recommend that you simply use GUI Textures and the iTween library to animate them, otherwise you may become really disappointed with the “OnGUI” situation, the more you try to customize it to your project.
iTween is found here. iTween for Unity by Bob Berkebile (pixelplacement)
If you have a few bucks to spend you may also try. http://www.anbsoft.com/middleware/ezgui/index.html
enjoy