Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Music : MonoBehaviour {
- public AudioSource audioPlayer;
- public ScreenManager sManager;
- void Start ()
- {
- audioPlayer = GetComponent<AudioSource> ();
- }
- void Update ()
- {
- }
- void CrossFadeMusic(AudioSource a1, AudioSource a2, float duration)
- {
- float v0 = a1.volume;
- a2.Play ();
- float t = 0;
- if (t < 1)
- {
- t = Mathf.Clamp01(t + Time.deltaTime / duration);
- a1.volume = (1 - t) * v0;
- a2.volume = t * v0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement