Синтаксис:
Используется javascript
using UnityEngine;
using System.Collections;
public class SoundManager : MonoBehaviour {
public float timeOut = 60; //Промежуток в секундах
public AudioSource sound;
private float time = 0;
// Use this for initialization
void Start () {
time = timeOut;
if(sound == null)
Debug.LogError("ERROR 404: Sound Not Found!");
}
// Update is called once per frame
void Update () {
if(time == timeOut){
sound.Play();
time = 0;
}
if(time < timeOut && !sound.isPlaying){
time += Time.deltaTime;
}
}
}
using System.Collections;
public class SoundManager : MonoBehaviour {
public float timeOut = 60; //Промежуток в секундах
public AudioSource sound;
private float time = 0;
// Use this for initialization
void Start () {
time = timeOut;
if(sound == null)
Debug.LogError("ERROR 404: Sound Not Found!");
}
// Update is called once per frame
void Update () {
if(time == timeOut){
sound.Play();
time = 0;
}
if(time < timeOut && !sound.isPlaying){
time += Time.deltaTime;
}
}
}