Hi I have a pause button that when pressed sets time to 0.
When it is at 0 I draw 2 buttons onto the screen, a resume and menu button.
I have two problems; when I click resumethe sound plays fine, when I click menu the sound cuts out too early, how can I fix this ? a tutor mentioned something about invoke.
Also another problem I have is scaling these two gui buttons to the screen resolution, how can I go about adapting code so the buttons scale with resolution ? thank you in advance.
my code is
using UnityEngine;
using System.Collections;
public class pauseScript : MonoBehaviour
{
bool Pause = false;
public GUIStyle ResumeStyle;
public GUIStyle MenuStyle;
void OnMouseUp() {
{
audio.Play();
if (Time.timeScale == 1)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
}
void OnGUI ()
{
if (Time.timeScale == 0)
{
if (GUI.Button (new Rect (Screen.width/2-50, Screen.height/2-25, 100, 50),"",ResumeStyle))
{
audio.Play();
Time.timeScale = 1;
}
if (GUI.Button (new Rect (Screen.width/2-50, (Screen.height/2-25)+60, 100, 50),"",MenuStyle))
{
audio.Play();
Time.timeScale = 1;
Application.LoadLevel ("MAINMENU");
}
}
}
}