- Home /
multi toch GUI buttons
I had two buttons on GUI. I need to press both buttons at a time .Is it possible with unity3d?
Answer by Ben Ezard · Jan 01, 2013 at 12:33 PM
It is possible, but you'll need to make your own buttons
Use GUITextures, and use the GUIElement.HitTest method to test if any touches are, well, touching them :D
(You'll need to iterate through all of the current touches)
Example script: var texture : GUITexture;
function Start() {
texture = gameObject.GetComponent(GUITexture);
}
function Update() {
for (var t : Touch in Input.touches) {
if (texture.HitTest(t.position, Camera.main)) {
//do something
}
}
} Just add that script to all your GUITextures that you want to act as buttons, and replace the "do something" comment with what you want the button to do :)
thank you Ben. i will check that method. is there any example scripts available?
I've edited my answer to include one :)
Also please mark my answer as correct so that other people know that the problem has been solved
Thanks
Your answer
Follow this Question
Related Questions
How do I make a custom font for a GUI button? C# 1 Answer
Tutorials for 2D game GUI 2 Answers
I want to move my cube using GUI buttons? 1 Answer
Only buttons closest to EventSystem (or last in the list under Canvas?) work. 1 Answer
How Can I Create Buttons In World Space and NOT Screen Space 2 Answers