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
1
Question by nagro · Apr 17, 2012 at 07:48 PM · buttongamepressask

you leave a question by pressing a button?

I want to press the button "exit" button or the "new game" to come out if you really want to go out or want to start a new game.

That leaves a question whether I really want to do that action.

I feel my English is that I use the translator.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by kevinseligmann · Apr 17, 2012 at 08:01 PM

Are you trying to make a GUI with those two buttons? If that's the case, for an exit button you could use:

 if (GUI.Button(Rect(10,10,50,30),"Click"))
     Application.Quit();

And for the New Game button well, are you working with scenes? Here's a little help about changing scenes from http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html

Hope that helps!

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 Lo0NuhtiK · Apr 17, 2012 at 08:03 PM 0
Share

Think (s)he's wanting an action confirmation pop-up of some sort. Like when you try to "Exit" , it then asks, "Are you sure you want to exit?" and you have to confirm it.

avatar image kevinseligmann · Apr 17, 2012 at 10:02 PM 0
Share

Yes, after he answered this question I realized he ment that. @T27$$anonymous$$ already posted an answer with the script, let's find out if that was what he was after.

avatar image
0

Answer by nagro · Apr 17, 2012 at 08:30 PM

if no button I have it done but what I need is pressing x button as you leave a window that says "want to get out of this game? Yes____NO"

Comment
Add comment · 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
0

Answer by T27M · Apr 17, 2012 at 09:58 PM

var exit : boolean = false;

var quit : boolean = false;

function OnGUI ()

{

 if(!exit && !quit && GUI.Button(Rect(0,0,100,100),"Quit Game"))

 {

     quit = true;

 }

 

 if(quit)

 {

     GUI.Label(Rect(130,0,200,100),"Would You like to quit the game?");

                 

     if(GUI.Button(Rect(120,20,100,100),"Yes"))

     {

         exit = true;

         quit = false;

     }

     

     if(GUI.Button(Rect(230,20,100,100),"No"))

     {

         quit = false;

     }

 }

     

 if(exit)

 {

     GUI.Label(Rect(130,0,200,100),"Are you sure?");

     

     if(GUI.Button(Rect(120,30,100,100),"Im Sure"))

     {

         Application.Quit();

         Debug.Log("Quit the game");

     }

     

     if(GUI.Button(Rect(230,30,100,100),"No,Wait!"))

     {

         exit = false;

         

     }

 }

 

 

}

I'm still new to unity but this works. Any critiques welcome.

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 tommi27 · Feb 01, 2015 at 02:13 AM 0
Share

I have the same problem! How can i interact with three window's buttons?

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

7 People are following this question.

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

Related Questions

Switch Camera On Button Press? 2 Answers

Animation pause on button press? 1 Answer

A node in a childnode? 1 Answer

Quit button 1 Answer

Play sound on button press? 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