예제 #1
0
        public void Awake()
        {
            if (_instance == null)
            {
                _instance = this;
                DontDestroyOnLoad(gameObject);

                _music = new FMODObject("event:/Music");
                _music.SetParameter("Music1", 0.0f);
                _music.SetParameter("Music2", 0.0f);
                _music.SetParameter("Music3", 0.0f);
                _music.SetParameter("Percussion", 0.0f);
                _music.Play();
                _wind = new FMODObject("event:/Wind");
                _bell = new FMODObject("event:/Bell");
                _bell.SetParameter("Volume", Bell);
                _steps        = new FMODObject("event:/Steps");
                _shovel       = new FMODObject("event:/Shovel");
                _pickupCoffin = new FMODObject("event:/PickupCoffin");
                _throwCoffin  = new FMODObject("event:/ThrowCoffin");
                _cart         = new FMODObject("event:/CartLoop");
                _cart.SetParameter("Volume", 0.75f);
                _raiseTomb = new FMODObject("event:/RaiseTomb");
                _tones     = new FMODObject("event:/Tones");
                _door      = new FMODObject("event:/GiantDoor");
            }
            else
            {
                Destroy(gameObject);
            }
        }
예제 #2
0
 public void Update()
 {
     _steps.SetParameter("Volume", StepsVolume);
         #if UNITY_EDITOR
     if (IsMuted)
     {
         Mute();
     }
     else
     {
         Unmute();
     }
         #endif
 }
예제 #3
0
        private IEnumerator Fade(FMODObject audio, string paramName, float endVolume, float duration_s, AudioAction f = null)
        {
            float t = 0.0f;
            float originalVolume = audio.GetParameter(paramName);
            float time           = Time.realtimeSinceStartup;

            while (t < 1.0f)
            {
                audio.SetParameter(paramName, Mathf.Lerp(originalVolume, endVolume, t));
                float dt = Time.realtimeSinceStartup - time;
                t   += dt / duration_s;
                time = Time.realtimeSinceStartup;
                yield return(null);
            }
            if (f != null)
            {
                f();
            }
        }
예제 #4
0
 public void CartVolume(float value)
 {
     _cart.SetParameter("Volume", value);
 }