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 darkcookie · Apr 06, 2012 at 11:07 PM · guibuttoncontinue

GUI create 2 buttons after activated when user clicks the mouse

my problem is that I want to make 2 GUI buttons apear when the player clicks on a button one saying "New Game" and the other "Continue" can some one pls help me

the code I used is :

 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{
 function OnGUI(){
     // Make a group on the center of the screen
     GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
     // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.
 
     // make a box for group
     GUI.Box (Rect (0,0,100,100), "Game Options");
     GUI.Button (Rect (10,40,80,30), "New Game");
     GUI.Button (Rect (10,50,80,30), "Continue");
 
     // End the group we started above
     GUI.EndGroup ();
 }
 }
 @script RequireComponent(AudioSource)
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
Best Answer

Answer by worldofcars · Apr 07, 2012 at 01:35 AM

var shownewgame : boolean = false;
var showcontinue : boolean = false;

function Update(){ }

function OnGUI(){
if(GUI.Button(Rect(0,0,200,30),"Show the other 2 buttons")){
shownewgame = true;
showcontinue = true;
}

 if(shownewgame == true){
     if(GUI.Button(Rect(0,40,200,30),"New Game")){
         //Code for new game button
     }
 }
 if(showcontinue == true){
     if(GUI.Button(Rect(0,80,200,30),"Continue")){
         //Code for continue button
     }
 }

}

//This must work;) If you have any questions, let me know;)

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 darkcookie · Apr 07, 2012 at 01:38 AM 0
Share

it works tnx

avatar image
0

Answer by poxqo · Apr 06, 2012 at 11:58 PM

You can make something like this:

 function OnGUI(){
    if GUI.Button (Rect (10,0,80,30), "Button that triggers two more btns");
    {
       if GUI.Button (Rect (10,40,80,30), "New Game");
       {
          // code for New Game Button
       }
       if GUI.Button (Rect (10,80,80,30), "Continue");
       {
          // code for Continue button
       }
    }
 }
 

This invokes a button that calls two more new buttons while pressed. PLEASE adjust the Rect coordinates in THIS code so they fit your own GUI design. Hope this helps you –if not, just let know :) Greetings from México.

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 darkcookie · Apr 07, 2012 at 12:38 AM 0
Share

it didnt work

avatar image
0

Answer by darkcookie · Apr 07, 2012 at 12:23 AM

alt text

I got all these errrors

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 worldofcars · Apr 07, 2012 at 01:22 AM 0
Share

The script is full of mistakes. I'll write you a new one

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

6 People are following this question.

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

Related Questions

How to continue a dialog (GUI.Label) with answering Buttons? 1 Answer

Make a Button out of a Textured Plane 2 Answers

[C#] Xbox D'Pad to cycle through GUI.Buttons? 2 Answers

Button Input 1 Answer

GUI.Button background image 0 Answers


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