- Home /
On-screen button press
How would I place a small GUI button on the screen in the top right corner and script for what to do when you click it? Also, what program would you recommend that I use to draw this GUI graphic.
Comment
Answer by fireDude67 · Jan 14, 2011 at 04:51 AM
void Update() {
if (GUI.Button(new Rect(Screen.width / 4 * 3, Screen.height / 4, 25, 10), "Example Text")) {
// The button has been clicked
}
}
This creates a standard GUI Button at 75% screen width, 25% screen height, 25 pixels wide, 10 pixels high.
Also check out http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html
Your answer
Follow this Question
Related Questions
Unity 3D C# - Buttons Need TO Press More Then Once 1 Answer
GUI.Button press (not click) 3 Answers
gui.button down 2 Answers
GUISkin breakages 2 Answers
Make a Button out of a Textured Plane 2 Answers