- Home /
How do I make an Android touch main menu?
I've been looking for a while now and I haven't been able to find anything really helpful. So I'm trying to make a 3d main menu with a play button and a quit button. For each button (cube with attached 3d text)I would like it to be where when you touch it, it loads a scene or quits the application. I've seen people using raycasting which I have no idea how to use as I am a novice coder. Is that the proper way to call upon an object in the scene. If so, what's a code that I could use for this function?
Answer by Kale · Nov 17, 2012 at 07:15 AM
I don't know about Android stuff but... Here's a start.
Look up raycasts, like you mentioned people have used. It literally casts a ray from one point to another. In cases of touchscreens and mice, you set it up to cast a ray from the point where you touch or click to a deeper spot in the scene. Then from there, you get the object that you hit to do something much like collision.
It seems you might be reaching way over your head at this point to look at making a menu without knowing at least the basics of raycasting, which would probably be at the core of any touchscreen or clicking game/app.
Answer by Bananaman · Nov 17, 2012 at 06:57 PM
Well before I just used OnMouseDown and so on for Pc games. But I looked at all the information on raycasting and touch input and got the whole thing running. Thanks!
Answer by LinuxHacker · Jun 18, 2013 at 10:26 AM
try using this script; attach a colider to the object you want to turn into a button and try it....
var levelToLoad : String;
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;
function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
if(QuitButton){
Application.Quit();
}
else{
Application.LoadLevel(levelToLoad);
}
}
@script RequireComponent(AudioSource)
u can use this video also :http://www.youtube.com/watch?v=Z8YGKQvEz1Y
Your answer
![](https://koobas.hobune.stream/wayback/20220613084012im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Raycast doesn't update 1 Answer
Unity c# Raycast axis stuck on one axis 0 Answers
Raycast lines debug problem 1 Answer
How to make sure that the raycast points in the right direction? 1 Answer
NavMesh AI: follow only if seen 1 Answer