Hello, how can I make something happen when my GUITexture is clicked? My GUITexture is “achieved” by this script which work’s fine btw
![]()
public Texture2D background;
int theHeight = 50;
int theWidth = 200;
void OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2 - (theWidth / 2), Screen.height - 50, theWidth, theHeight), background);
}
Thanks, Andreas ![]()
Thank you :D, how can I remove the "border" of the button, so that it look's like the DrawTexture? :-)
– AndreasX12Isn't an easier option to just change the style of the button?
– Unitraxx@Unitraxx - possibly. I always reach for code. @AndreasX12 as @Unitraxx points out you can change your button style instead of the code posted above. Here is a link: [http://docs.unity3d.com/Documentation/Components/gui-Customization.html][1]. [1]: http://docs.unity3d.com/Documentation/Components/gui-Customization.html
– robertbuThank you all for the answers, I figured it out now, using the Custom gui style :-)
– AndreasX12I've run into an issue when trying to implement the code in the second part. I'm getting a semi colon error (syntax) when I have nothing missing. Any suggestions? var playButton:GUITexture; void onGUI() { Event e = Event.current; if (e.type == EventType.MouseUp) { if (playButton.contains(e.mousePosition) { // Perform Action } } }
– GoldenHeartedTechnologies