Problemas no sistema de Pause!
2 participantes
Página 1 de 1
Problemas no sistema de Pause!
Deem um helo aki plz,criei um sistema de pause,parecido com o do Paulo na seri3 do slender,no editor ele funfa perfeitamente,porem no jogo (dps de buildado) eu aperto o esc no caso e a tela de pause aparece por menos de 1 sec e some bem rapido!!
SCRIPT DO GAME CONTROLLER
SCRIPT DO HUD DO PAUSE:
SCRIPT DO GAME CONTROLLER
- Código:
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
private bool isPaused = false;
private bool callPause = false;
private bool callUnPause = false;
public AudioSource playerSound;
public AudioSource soundIn;
public AudioSource soundOut;
private AudioSource[] audiosGame;
// Use this for initialization
void Start () {
audiosGame = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
foreach(AudioSource tempAudio in audiosGame){
tempAudio.volume = PlayerPrefs.GetFloat("CurrentVolume");
}
}
// Update is called once per frame
void Update () {
if (callPause) {
callPause = false;
isPaused = true;
Time.timeScale = 0;
playerSound.Stop ();
soundIn.volume = 0;
soundOut.volume = 0;
}
if (callUnPause) {
callUnPause = false;
isPaused = false;
Time.timeScale = 1;
soundIn.volume = PlayerPrefs.GetFloat ("CurrentVolume");
;
soundOut.volume = PlayerPrefs.GetFloat ("CurrentVolume");
;
}
}
public void PauseGame(){
if(isPaused){
callUnPause = true;
}
else{
callPause = true;
}
}
public bool IsPausedGame(){
return isPaused;
}
}
SCRIPT DO HUD DO PAUSE:
- Código:
using UnityEngine;
using System.Collections;
public class HUDGameController : MonoBehaviour {
private GameController gameController;
public Texture backGroundPause;
public GUISkin guiSkinToUse;
// Use this for initialization
void Start () {
gameController = FindObjectOfType(typeof(GameController)) as GameController;
}
// Update is called once per frame
private void Update () {
if(Input.GetKeyDown(KeyCode.Escape)){
gameController.PauseGame();
}
}
void OnGUI(){
GUI.skin = guiSkinToUse;
if(gameController.IsPausedGame()){
Update();
GUI.DrawTexture(new Rect(0,0, Screen.width, Screen.height), backGroundPause);
GUILayout.BeginArea(new Rect(Screen.width/2-150, Screen.height-(0.8f*Screen.height), 300, Screen.height));
if(GUILayout.Button("Resume Game")) gameController.PauseGame();
GUILayout.Space(10);
if(GUILayout.Button("Exit To Menu")){
gameController.PauseGame();
Application.LoadLevel("MainMenu");
}
GUILayout.EndArea();
}
}
breno1086- Membro
- PONTOS : 3411
REPUTAÇÃO : 1
Respeito as regras :
Re: Problemas no sistema de Pause!
Tinha alguns errinhos... Tenta ver agora:
e
- Código:
using UnityEngine;
using System.Collections;
public class HUDGameController : MonoBehaviour {
private GameController gameController;
public Texture backGroundPause;
public GUISkin guiSkinToUse;
void Start () {
gameController = FindObjectOfType(typeof(GameController)) as GameController;
}
private void Update () {
if(Input.GetKeyDown(KeyCode.Escape)){
gameController.PauseGame();
}
}
void OnGUI(){
GUI.skin = guiSkinToUse;
if(gameController.IsPausedGame()){
GUI.DrawTexture(new Rect(0,0, Screen.width, Screen.height), backGroundPause);
GUILayout.BeginArea(new Rect(Screen.width/2-150, Screen.height-(0.8f*Screen.height), 300, Screen.height));
if(GUILayout.Button("Resume Game")){
gameController.PauseGame();
}
GUILayout.Space(10);
if(GUILayout.Button("Exit To Menu")){
gameController.PauseGame();
Application.LoadLevel("MainMenu");
}
GUILayout.EndArea();
}
}
}
e
- Código:
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
private bool isPaused = false;
private bool callPause = false;
private bool callUnPause = false;
public AudioSource playerSound;
public AudioSource soundIn;
public AudioSource soundOut;
private AudioSource[] audiosGame;
void Start () {
audiosGame = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
foreach(AudioSource tempAudio in audiosGame){
tempAudio.volume = PlayerPrefs.GetFloat("CurrentVolume");
}
}
void Update () {
if (callPause) {
callPause = false;
isPaused = true;
Time.timeScale = 0;
playerSound.Stop ();
soundIn.volume = 0;
soundOut.volume = 0;
}
if (callUnPause) {
callUnPause = false;
isPaused = false;
Time.timeScale = 1;
soundIn.volume = PlayerPrefs.GetFloat ("CurrentVolume");
soundOut.volume = PlayerPrefs.GetFloat ("CurrentVolume");
}
}
public void PauseGame(){
if(isPaused){
callUnPause = true;
}
else{
callPause = true;
}
}
public bool IsPausedGame(){
return isPaused;
}
}
Re: Problemas no sistema de Pause!
VLW cara,funfou,sempre me ajudando,tu eh foda mano! Seu canal mereçe tudo sucesso possível!
breno1086- Membro
- PONTOS : 3411
REPUTAÇÃO : 1
Respeito as regras :
Tópicos semelhantes
» [DUVIDA] Menu Pause
» SISTEMA PAUSE - FPSController
» PAUSE PARCIAL
» Menu De Pause De Um FPS
» problema no Menu Pause
» SISTEMA PAUSE - FPSController
» PAUSE PARCIAL
» Menu De Pause De Um FPS
» problema no Menu Pause
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos