I been souring the forums, can’t seem to find what I am trying to do, basically I want to have a simple GUI with touch on the iPhone, does anyone have a quick example of how to do a Gui button on the iPhone with touch detection? (everything I was doing before was via keyboard on the regular build of the game, I want to replace my Input.GetKey(“blahs”) with different on gui touch events. Second problem I have, is that I have a makeshift border around the game, but visually it is incorrect when in the player compared to what it is, in the mean time, I am fixing that by making the border outside the range fo the visual interface. I just need to deal with the GUI and this baby is ready to go!
you should check out the example files, they are very helpful. Are you looking for something like this - Input.GetMouseButtonDown (0). This was in the match example.
iPhone touch example, not mouse down, gui for the iphone example, there are tons of people around that have iphone apps now on the apple store with menus and saved games and touch events, the only example that was with the package I got was some space thing, no menu, only a touch to fire a missile, i looked through the docs and don’t understand it at the moment, i’ll take your advice and see if i can figure out touch to mouse down type event
touch = mouse down
Basically all the GUI stuff on the iPhone works the same way as it wold normally do; e.g. something like if(GUI.Button(…)) {} works on iPhone too. If you want to do more specific touch handling (multitouch, gestures…) have a look at the iPhoneTouch struct.
file:///Applications/Unity%20iPhone/Unity%20iPhone.app/Contents/Documentation/Documentation/ScriptReference/iPhoneTouch.html
zumwalt, try this script … call it LoadNextScene.js or whatever and attach it to an empty game object in a scene.
function OnGUI ()
{
// two buttons on screen from left to right
// show next/previous instructions screen or go to menu scene
// go to menu scene
if (GUI.Button (Rect (17,260,50,50), "Menu")) {
Application.LoadLevel ("menu");
}
// show next instructions scene
if (GUI.Button (Rect (413,260,50,50), "Next")) {
Application.LoadLevel ("instructions2");
}
}
You can do all the normal stuff to like make a custom GUI skin and assign it at the script’s beginning, etc.