Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ReflexGames · Jul 31, 2014 at 08:32 PM · androidguitextgame

Level Button And Quit Button Android

Hey I am making a game for Android and on my main menu I have three buttons, Campaign, Options and Quit. I am very bad at coding, and have almost no experience in coding. I have made some other games for android and PC, but the buttons on the Android games were really simple, as they were just tap anywhere to play. but I have looked around everywhere for this and i can't find any answers. Could someone help me? All i need is a code to quit the app and a code when i press the GUI Text it goes to the level i want.

Thanks!

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Jul 31, 2014 at 08:41 PM 0
Share

C#:

Closing: Application.Quit();

Level: Application.LoadLevel(numberOfLevel);

avatar image ReflexGames · Jul 31, 2014 at 08:45 PM 0
Share

Thanks $$anonymous$$an

avatar image ReflexGames · Jul 31, 2014 at 08:46 PM 0
Share

But how do I make the touch Input part?

avatar image Serdnad · Jul 31, 2014 at 08:47 PM 0
Share

That's the beauty of it, Unity takes Input.mouseButton(0) as a touch, the same way it takes it as a click on a pc.

avatar image ReflexGames · Jul 31, 2014 at 09:59 PM 0
Share

Ok That Helps Sooo $$anonymous$$uch Thanks, i never knew that!

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Serdnad · Jul 31, 2014 at 08:46 PM

Same way you would do it for a PC Game.

 void OnGUI ()
     {
         if(GUI.Button(new Rect(Screen.width/8, Screen.height/2, Screen.width/4, Screen.height/4), "Level 1"))
         {
             Application.LoadLevel("Level 1");
         }
         else if(GUI.Button(new Rect(Screen.width/2, Screen.height/2, Screen.width/4, Screen.height/4), "Quit"))
         {
             Application.Quit();
         }
     }

Just change the positions and widths, and that should be good. And you can make it look better by using your own picture, or playing with the font and borders and colors, in which case you should look up GUIStyle if you're interested in that.

Also, the else in the second if statement is optional, but since it's impossible to click both buttons at the exact same time, it does no harm.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ReflexGames · Jul 31, 2014 at 09:09 PM 0
Share

Thanks helped alot!

avatar image Serdnad · Aug 01, 2014 at 04:48 AM 0
Share

@ReflexGames, Glad I was able to help :). Would you $$anonymous$$d marking it correct if it answered your question?

avatar image
0

Answer by keburanuil · Jul 31, 2014 at 08:47 PM

 var levelToLoad : int;
 var quitButton : boolean;
 
 function OnMouseDown()
 {
     if (quitButton)
         Application.Quit();
     else
         Application.LoadLevel(levelToLoad);
 }

Add this script to your buttons and setup it in inspector. Works on pc/mac and mobile.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ReflexGames · Jul 31, 2014 at 09:08 PM 0
Share

Thank You!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Gui text script - help 1 Answer

[Android] Why does my enemy die no matter where I am in the 3D environment? 1 Answer

Using "fonts" that are actually images for a multi-outline effect. 2 Answers

Zoom at Text 1 Answer

GUI HELP!!!!! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges