Сообщение от Lestar
AudioSource[] AOAS = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
for (int i = 0; i < AOAS.Length; i++)
{
AOAS[i].Pause();
}
|
Спасибо, но вот как теперь продолжать то звук???
using UnityEngine;
using System.Collections;
public class Pause : MonoBehaviour {
public bool IsPause = false;
private CharacterController controller;
void Start()
{
controller = transform.GetComponent<CharacterController>();
}
void Update()
{
AudioSource[] AOAS = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
if(Input.GetKeyDown(KeyCode.Escape) && IsPause == false && controller.isGrounded)
{
Time.timeScale = 0;
transform.GetComponent<MouseLook>().enabled = false;
transform.FindChild("Main Camera").GetComponent<MouseLook>().enabled = false;
for (int i = 0; i < AOAS.Length; i++)
{
AOAS[i].Pause();
}
IsPause = true;
}
else
{
if(Input.GetKeyDown(KeyCode.Escape) && IsPause == true)
{
Time.timeScale = 1;
transform.GetComponent<MouseLook>().enabled = true;
transform.FindChild("Main Camera").GetComponent<MouseLook>().enabled = true;
for (int i = 0; i > AOAS.Length; i--)
{
AOAS[i].Play();
}
IsPause = false;
}
}
}
}