Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - RyuuzakiBjorn

Pages: [1]
1
NGUI 3 Support / Using NGUI for pause menu
« on: February 18, 2014, 12:51:20 PM »
Hi everyone, this is my first post!
I've got a little question which I can't seem to figure out the answer to, and was wondering if you guys 'n gals can help me out.
I've created a GUI in UIRoot for a pause menu. I've created a script to pause the game but I'm unsure how I can make the NGUI UI appear when the pause button is pressed and dissapear when players press the pause button again.

It sounds so simple, but I can't figure it out.

My current code:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Pause : MonoBehaviour {
  5.  
  6.         private bool pauseEnabled = false;             
  7.        
  8.         void  Start (){
  9.                 pauseEnabled = false;
  10.                 Time.timeScale = 1;
  11.                 AudioListener.volume = 1;
  12.                 Screen.showCursor = false;
  13.         }
  14.        
  15.         void  Update (){
  16.                
  17.                 if(Input.GetButtonDown ("pauseButton")){
  18.                        
  19.                         if(pauseEnabled == true){
  20.                                 pauseEnabled = false;
  21.                                 Time.timeScale = 1;
  22.                                 AudioListener.volume = 1;
  23.                                 Screen.showCursor = false;                     
  24.                         }
  25.                        
  26.                         else if(pauseEnabled == false){
  27.                                 pauseEnabled = true;
  28.                                 AudioListener.volume = 0;
  29.                                 Time.timeScale = 0;
  30.                                 Screen.showCursor = true;
  31.                         }
  32.                 }
  33.         }
  34. }

How would I make it hide/unhide my NGUI ui when the game is paused?

Thanks in advance for the help!
- R

Pages: [1]