Exemple #1
0
 IEnumerator SourceFading(FadeSetting setting)
 {
     if (setting.source != null)
     {
         float t = Time.time;
         float rate;
         float vol = setting.source.volume;
         do
         {
             rate = setting.fadeCurve.Evaluate(Time.time - t);
             setting.source.volume = vol * rate;
             yield return(new WaitForEndOfFrame());
         } while (rate > 1e-5f);
         if (setting.StopAfterFaded)
         {
             setting.source.Stop();
             setting.source.volume = vol;
         }
         if (setting.DisableAfterFaded)
         {
             setting.source.gameObject.SetActive(false);
             setting.source.volume = vol;
         }
     }
 }
        private void Reset()
        {
            // Apply default properties when created or reset in the editor.
            color = Color.black;

            preFadeSettings = new FadeSetting
            {
                duration = 0.4f,
                curve    = AnimationCurve.Linear(0f, 0f, 1f, 1f)
            };

            postFadeSettings = new FadeSetting
            {
                duration = 0.4f,
                curve    = AnimationCurve.Linear(0f, 0f, 1f, 1f)
            };

            description = "The 'fade to color' transition animator creates a color fade " +
                          "transition between screens.\n\nIt will first fade from the source content to " +
                          "the specified color - the 'pre-fade' - and then fade from the specified color " +
                          "to the destination content - the 'post-fade'.";
        }