x


How to make 2D pop up box

how can i create a 2D pop up box like Angry Bird games, when we want to quit the game. it will pop a image either you click right and x button.. sorry im a newbie with unity..thanks

more ▼

asked Jan 09 '12 at 05:06 PM

faez gravatar image

faez
1 3 3 3

@faez,

Your post is probably too general for UnityAnswers. The UnityAnswers philosophy is:

"[Unity Answers] is a place to ask specific questions that have specific answers. The forum is a better place to post discussions and non-technical questions."

As a general rule, posts should probably have the following:

  • A clear question (what, specifically, are you trying to do?)
  • Relevant background information (what have you already tried? what other things might be important for us to know?)
  • Context information (what do you expect to happen? What is happening instead?)

If your post is one of the following, you should consider changing it or asking on the forums instead:

  • A one- or couple-sentence post, especially with a broad question ("how do I make a game like Halo?") or no discernible question ("WebPlayer doesn't allow me to save to disk"). We'll need more specific information to help you.
  • Asking the opinion of the community ("Best method to store files?"). Much better to discuss these on the forums.
  • A question that focuses on the end result, rather than anything technical ("how do I make a laser beam?"). These mean that you probably haven't done enough research. If you're just starting out and don't even know where to look, try searching here, the forums, and Google first and then posting your question to the forums. The Unity resources are a great place to start (http://unity3d.com/support/resources/). When you get to a more technical point ("how do I adjust the color of a line renderer for a laser beam?") we can probably help you.
  • A disjointed or incomplete question ("How do I make a jumping enemy? Physics doesn't look right."). It will help us if you take a moment to add some context information, background, and general explanation.

Of course, the members here are awesome folks and will probably try to help you anyway - hopefully you'll get an answer or some helpful comments. If not, now you know why.

Jan 09 '12 at 06:26 PM Julien.Lynge
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

The GUI interface in Unity makes that really easy.

Create an empty GameObject and add a script with something like the following:

Rect _quitWindowRect = new Rect ( Screen.width/2-125, Screen.height/2-25, 250, 50 );

void OnGUI()
{
  if ( quitRequested )
  {
     GUI.Window ( QUIT_WINDOW_ID, _quitWindowRect, QuitWindowFunction, "Quit?" );
  }
}

void QuitWindowFunction ( int id )
{
  if ( GUI.Button ( new Rect ( 10, 10, 100, 30 ), "yes" )
  {
    // TODO: shut down the game...
  }
  if ( GUI.Button ( new Rect ( 120, 10, 100, 30 ), "NO!!" )
  {
    // TODO: return to game
  }

}
more ▼

answered Jan 09 '12 at 11:15 PM

royce3 gravatar image

royce3
76 1 1 3

(comments are locked)
10|3000 characters needed characters left

thanks for your answer royce3...

more ▼

answered Jan 10 '12 at 03:53 AM

faez gravatar image

faez
1 3 3 3

you're welcome. Would you please go ahead and accept my answer?

Thanks

Jan 18 '12 at 02:16 PM royce3
(comments are locked)
10|3000 characters needed characters left

that coding got error... it say (UCE0001: ';' expected. Insert a semicolon at the end.)

more ▼

answered Jan 18 '12 at 10:44 PM

Akmal gravatar image

Akmal
36 10 12 15

I was merely showing you the structure of code needed. If you need tutorials on how to write code you should search the web for such.

Jan 19 '12 at 02:45 PM royce3
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x36

asked: Jan 09 '12 at 05:06 PM

Seen: 1998 times

Last Updated: Jan 19 '12 at 02:45 PM