using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Audio;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class PauseManager : MonoBehaviour {
public AudioMixerSnapshot paused;
public AudioMixerSnapshot unpaused;
Canvas canvas;
void Start()
{
canvas = GetComponent<Canvas>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
canvas.enabled = !canvas.enabled;
Pause();
}
}
public void Pause()
{
Time.timeScale = Time.timeScale == 0 ? 1 : 0;
Lowpass ();
}
void Lowpass()
{
if (Time.timeScale == 0)
{
paused.TransitionTo(.01f);
}
else
{
unpaused.TransitionTo(.01f);
}
}
public void Quit()
{
#if UNITY_EDITOR
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
————————————————————————————————————————————————
using UnityEngine;
using System.Collections;
using UnityEngine.Audio;
public class MixLevels : MonoBehaviour {
public AudioMixer masterMixer;
public void SetSfxLvl(float sfxLvl)
{
masterMixer.SetFloat("sfxVol", sfxLvl);
}
public void SetMusicLvl (float musicLvl)
{
masterMixer.SetFloat ("musicVol", musicLvl);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。