- Home /
EXTREMELY basic button question.
I realise that this is a bit of a stupid question but i've been googling it for the past 20 mins and I still can't find the answer. I have a GUITexture on my iPhone app and I want to detect a touch of it. How do I do this?
Answer by Mike 3 · Jun 19, 2010 at 12:31 PM
You just use the standard OnMouseEnter/Exit/Down/Up event functions:
function OnMouseDown()
{
//do stuff
}
Edit (since you're on iPhone):
http://answers.unity3d.com/questions/2807/simple-touch-command-on-iphone
The question and answer there should be enough to get you going
You'll probably need to add a trigger collider to the GUITexture (and may want to use collider.Raycast instead of Physics.Raycast)
The problem is i'm using Unity iPhone so "On$$anonymous$$ouseDown" doesn't work? Thanks anyway.
Answer by Zachary · Dec 23, 2010 at 06:22 AM
Usually when you have a GUI texture it wont work it will just appear on your screen so what i do is put a text box, and that usually works and create a script for the button for it to highlight and stuff whatever else you want it to do. which is in the same category in the tool bar with GUI text.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to support Retina display 1 Answer
How do I invert the Y axis in Penelope tutorial? 3 Answers
how to create buttons using iphone look and feel?? 2 Answers
Compiling in Xcode? 0 Answers