示例#1
0
        public void Fade(FadeType _fadeType, float _fadeTime, float startAlpha = -1)
        {
            StopCoroutine ("DoFade");

            float currentAlpha = spriteRenderer.color.a;

            if (startAlpha >= 0)
            {
                currentAlpha = startAlpha;
                SetAlpha (startAlpha);
            }

            if (_fadeType == FadeType.fadeOut)
            {
                fadeStartTime = Time.time - (currentAlpha * _fadeTime);
            }
            else
            {
                fadeStartTime = Time.time - ((1f - currentAlpha) * _fadeTime);
            }

            fadeTime = _fadeTime;
            fadeType = _fadeType;

            StartCoroutine ("DoFade");
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NotifyWindow"/> class.
        /// Displays an empty notification.
        /// </summary>
        public NotifyWindow()
        {
            InitializeComponent();

            numPixelsFade = Settings.Default.NotificationFadePixels;
            fadeType = (FadeType) Settings.Default.NotificationFadeType;
        }
        private FadeType type; // Fade in or fade out.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public StateScreenFade(Color color, float duration, FadeType type)
            : base()
        {
            this.color     = color;
            this.duration  = duration;
            this.type      = type;
        }
示例#4
0
 public UiAnimationFade(GameObject gameobject, float duration, FadeType fadeType) : base(gameobject)
 {
     Canvas = gameobject.GetOrAddComponent<CanvasGroup>();
     Canvas.alpha = fadeType == FadeType.In ? 0f : Canvas.alpha;
     Duration = duration;
     Fade = fadeType;
 }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public TransitionFade(Color color, int duration, FadeType type, GameState gameState)
 {
     this.duration	= duration;
     this.timer		= 0;
     this.type		= type;
     this.color		= color;
     this.gameState	= gameState;
 }
示例#6
0
 void DrawCameraFlashButton()
 {
     if ( GUILayout.Button( "Flash/Lightning" ) ) {
         fadeDirection = false;
         currentFadeType = FadeType.Flash;
         ScreenFade.Fade( Color.white, 1, 0, .5f, 0, true );
         PlaySound( cameraShutterSound, 0 );
     }
 }
示例#7
0
 public StopSettings(bool onBeat, Metronome metronome, SnapStyle snapStyle, float beat, float delay, float fadeLength, FadeType fadeType, float power)
 {
     this.onBeat = onBeat;
     this.metronome = metronome;
     this.snapStyle = snapStyle;
     this.beat = beat;
     this.delay = delay;
     this.fadeLength = fadeLength;
     this.fadeType = fadeType;
     this.power = power;
 }
示例#8
0
 public void ImitateTrail(SplineTrailRenderer trail)
 {
     emit = trail.emit;
     emissionDistance = trail.emissionDistance;
     height = trail.height;
     width = trail.width;
     vertexColor = trail.vertexColor;
     normal = trail.normal;
     meshDisposition = trail.meshDisposition;
     fadeType = trail.fadeType;
     fadeLengthBegin = trail.fadeLengthBegin;
     fadeLengthEnd = trail.fadeLengthEnd;
     maxLength = trail.maxLength;
     debugDrawSpline = trail.debugDrawSpline;
     GetComponent<Renderer> ().material = trail.GetComponent<Renderer> ().material;
 }
示例#9
0
        /**
         * <summary>Fades the Sprite attached to this GameObject in or out.</summary>
         * <param name = "_fadeType">The direction of the fade effect (fadeIn, fadeOut)</param>
         * <param name = "_fadeTime">The duration, in seconds, of the fade effect</param>
         * <param name = "startAlpha">The alpha value that the Sprite should have when the effect begins. If <0, the Sprite's original alpha will be used.</param>
         */
        public void Fade(FadeType _fadeType, float _fadeTime, float startAlpha = -1)
        {
            StopCoroutine ("DoFade");

            float currentAlpha = spriteRenderer.color.a;

            if (startAlpha >= 0)
            {
                currentAlpha = startAlpha;
                SetAlpha (startAlpha);
            }
            else
            {
                if (spriteRenderer.enabled == false)
                {
                    spriteRenderer.enabled = true;
                    if (_fadeType == FadeType.fadeIn)
                    {
                        currentAlpha = 0f;
                        SetAlpha (0f);
                    }
                }
            }

            if (_fadeType == FadeType.fadeOut)
            {
                fadeStartTime = Time.time - (currentAlpha * _fadeTime);
            }
            else
            {
                fadeStartTime = Time.time - ((1f - currentAlpha) * _fadeTime);
            }

            fadeTime = _fadeTime;
            fadeType = _fadeType;

            if (fadeTime > 0f)
            {
                StartCoroutine ("DoFade");
            }
            else
            {
                EndFade ();
            }
        }
示例#10
0
    //-----------------------------------------------------------------------------
    // Private Methods
    //-----------------------------------------------------------------------------
    void DrawFadeButton()
    {
        //decide text to display on the button based on state of fadeDirection:
        string fadeText = fadeDirection ? "down" : "up";

        if ( GUILayout.Button( "Fade " + fadeText ) ) {
            //set type of fadeDirection:
            currentFadeType = FadeType.Fade;

            //toggle state of fadeDirection:
            fadeDirection = !fadeDirection;

            //fade up or down based on state of fadeDirection:
            if (fadeDirection) {
                ScreenFade.Fade( Color.black, ScreenFade.CurrentAlpha, 1, 1, 0, false );
            }else{
                ScreenFade.Fade( Color.black, ScreenFade.CurrentAlpha, 0, 1, 0, false );
            }
        }
    }
示例#11
0
    public void SetFadeLevel(FadeType type, float val)
    {
        switch (this.m_FadeType)
        {
        case FadeType.Vis:
            this.m_FadeLevel1[0] = val;
            return;

        case FadeType.Sound:
            this.m_FadeLevel1[1] = val;
            return;

        case FadeType.All:
            this.m_FadeLevel1[0] = val;
            this.m_FadeLevel1[1] = val;
            return;

        default:
            return;
        }
    }
示例#12
0
    private IEnumerator FadeImage <T>(T target, FadeType fadeType, float duration) where T : Graphic
    {
        if (target == null)
        {
            yield break;
        }

        float startAlpha = fadeType == FadeType.FadeIn ? 0 : 1;

        target.color = new Color(0, 0, 0, startAlpha);
        var finalColor = new Color(0, 0, 0, startAlpha >= 0 ? 0 : 1);

        for (var t = 0.0f; t < 1.0f; t += Time.unscaledDeltaTime / duration)
        {
            target.color = new Color(finalColor.r, finalColor.g, finalColor.b, Mathf.SmoothStep(startAlpha, finalColor.a, t));
            yield return(null);
        }

        target.raycastTarget = fadeType != FadeType.FadeOut;
        Destroy(target.gameObject);
    }
示例#13
0
 // Update is called once per frame
 private void FixedUpdate()
 {
     if (fadeType == FadeType.FADE_IN) // ! fade in sprite
     {
         GetComponent <SpriteRenderer>().color = new Color(color().r, color().g, color().b, color().a + (1.0f / fadeAwayFrames));
         if (color().a >= 1 - (1.0f / fadeAwayFrames))
         {
             fadeType = FadeType.FADE_OUT;
         }                                   // ! when fully opaque : fade out
     }
     else if (fadeType == FadeType.FADE_OUT) // ! fade out and shrink
     {
         GetComponent <SpriteRenderer>().color = new Color(color().r, color().g, color().b, color().a - (1.0f / fadeAwayFrames));
         Vector3 imageScale = transform.localScale;
         transform.localScale = new Vector3(imageScale.x - 0.01f, imageScale.y - 0.01f, 1.0f);
         if (color().a <= 0 + (1.0f / fadeAwayFrames)) // ! when faded out remove death image
         {
             Destroy(gameObject);
         }
     }
 }
示例#14
0
        public static FadeType Opposite(this FadeType type)
        {
            if (type == FadeType.Fast)
            {
                return(FadeType.Slow);
            }
            if (type == FadeType.Slow)
            {
                return(FadeType.Fast);
            }
            if (type == FadeType.Hold)
            {
                return(FadeType.Release);
            }
            if (type == FadeType.Release)
            {
                return(FadeType.Hold);
            }

            return(type);
        }
示例#15
0
        public void FadeOut(float _timeToFade)
        {
            AssignFadeTexture();

            if (alpha == 0f)
            {
                alpha = 0.01f;
            }
            if (_timeToFade > 0f)
            {
                alpha         = Mathf.Clamp01(alpha);
                timeToFade    = _timeToFade;
                fadeType      = FadeType.fadeOut;
                fadeStartTime = Time.time - (alpha * timeToFade);
            }
            else
            {
                alpha      = 1f;
                timeToFade = 0f;
            }
        }
示例#16
0
    /// <summary>
    /// Fades the music.
    /// </summary>
    /// <returns>The music.</returns>
    /// <param name="aFadeType">A fade type.</param>
    public IEnumerator FadeMusic(FadeType aFadeType)
    {
        //Here we make sure that we have access to the globalData file, this way we can referance the saved music volume,
        // if we do not have a reference, just set the volume to the default sound volume
        float currentSoundLevel = (aFadeType == FadeManager.FadeType.FadeIn)
                                                                ? ((DataManager.globalData != null)
                                                ? DataManager.globalData.MusicVolume : WorldConstants.DEFAULT_MUSIC_V)
                                                                        : SoundManager.Instance.musicSource.volume;

        float _soundValue = (aFadeType == FadeType.FadeIn) ? 0.0f : 1.0f;

        while (((aFadeType == FadeType.FadeIn) ? (_soundValue < 1.0f) : (_soundValue > 0.0f)))
        {
            _soundValue += ((aFadeType == FadeType.FadeIn) ? 1 : -1) * (1 * (float)fadeTransitionSpeed / 100.0f) * Time.deltaTime;
            SoundManager.Instance.musicSource.volume = currentSoundLevel * _soundValue;
            yield return(null);
        }

        //Once completed exit coroutine
        yield return(null);
    }
示例#17
0
 public static IEnumerator FadeGroup(Graphic[] objs, FadeType fade, float duration, float mult = 1)
 {
     for (float i = 0; i <= duration; i += Time.unscaledDeltaTime)
     {
         for (int j = 0; j < objs.Length; j++)
         {
             if (objs[j] != null)
             {
                 objs[j].color = new Color(objs[j].color.r, objs[j].color.g, objs[j].color.b, Mathf.Abs(((int)fade) - (i / duration)) * mult);
             }
         }
         yield return(null);
     }
     for (int j = 0; j < objs.Length; j++)
     {
         if (objs[j] != null)
         {
             objs[j].color = new Color(objs[j].color.r, objs[j].color.g, objs[j].color.b, (1 - Mathf.Abs(((int)fade)) * mult));
         }
     }
 }
示例#18
0
        static List <double> _KeyframeTimes(FadeType type, double duration)
        {
            switch (type)
            {
            case FadeType.FadeIn:
                return(new List <double>()
                {
                    0, duration / 6, duration
                });

            case FadeType.FadeOut:
                return(new List <double>()
                {
                    0, duration / 6, duration
                });
            }
            return(new List <double>()
            {
                0, duration / 6, duration
            });
        }
示例#19
0
        /// <summary>
        /// Generates linear fade in and/or fade out effect for specified signal
        /// </summary>
        /// <param name="signal">Source signal</param>
        /// <param name="fadePart">a part of signal to fade in [0..1], where 1 - full signal length</param>
        /// <param name="fadeType"></param>
        public static void LinearFade(ref double[] signal, double fadePart, FadeType fadeType)
        {
            int    fadeLength = (int)(signal.Length * fadePart);
            double delta      = 1.0 / fadeLength;

            bool isFadeIn  = ((fadeType & FadeType.fadeIn) == FadeType.fadeIn);
            bool isFadeOut = ((fadeType & FadeType.fadeOut) == FadeType.fadeOut);

            for (int i = 0; i < fadeLength; i++)
            {
                if (isFadeIn)
                {
                    signal[i] = (short)(signal[i] * delta * i);
                }

                if (isFadeOut)
                {
                    signal[signal.Length - i - 1] = (short)(signal[signal.Length - i - 1] * delta * i);
                }
            }
        }
    IEnumerator FadePageImage(FadeType _fadeType)
    {
        previousButton.interactable     = false;
        nextButton.interactable         = false;
        audioHistoryButton.interactable = false;

        //Fade out page image
        if (currentPage.pageAnimator != null)
        {
            currentPage.pageAnimator.SetTrigger(fadeOut);
            yield return(new WaitForSeconds(currentPage.pageAnimator.GetCurrentAnimatorStateInfo(0).length));
        }

        currentPage.pageImage.SetActive(false);

        if (_fadeType == FadeType.PreviousPage && PageIndex > 0)
        {
            PageIndex--;
            ValidatePageIndex();
        }
        else if (_fadeType == FadeType.NextPage)
        {
            PageIndex++;
            ValidatePageIndex();
        }

        try
        {
            currentPage = pageList[PageIndex];
            currentPage.pageImage.SetActive(true);
        }
        catch
        {
            yield break;
        }

        yield return(new WaitForSeconds(currentPage.pageAnimator.GetCurrentAnimatorStateInfo(0).length));

        PlayCurrentPageAudio();
    }
示例#21
0
    //// Fade in the GUITexture, wait a couple of seconds, then fade it out
    //public void Start () {
    //   yield FadeGUITexture(guiObject, fadeTime, FadeType.In);
    //   yield WaitForSeconds(2.0);
    //   yield FadeGUITexture(guiObject, fadeTime, FadeType.Out);
    //   Application.LoadLevel (Application.loadedLevel+1);
    //   }


    public static IEnumerator FadeGUITexture(this Texture2D texture, float seconds, FadeType fadeType)
    {
        float start = (float)(fadeType == FadeType.In ? 0.0 : 1.0);
        float end   = (float)(fadeType == FadeType.In ? 1.0 : 0.0);
        float i     = 0.0f;
        float step  = 1.0f / seconds;

        while (i < 1.0)
        {
            i += step * Time.deltaTime;
            Color[] newColors = new Color[texture.GetPixels().Length];

            int x = 0;
            foreach (Color color in texture.GetPixels())
            {
                newColors[x] = new Color(color.r, color.g, color.b, Mathf.Lerp(start, end, i) * .5f);
            }
            texture.SetPixels(newColors);
            texture.Apply();
            yield return(null);
        }
    }
示例#22
0
        public static IEnumerator FadeSceneOut(FadeType fadeType)
        {
            CanvasGroup canvasGroup;

            switch (fadeType)
            {
            case FadeType.Win:
                canvasGroup = _instance.winCanvasGroup;
                break;

            case FadeType.Death:
                canvasGroup = _instance.deathCanvasGroup;
                break;

            default:
                canvasGroup = _instance.menuCanvasGroup;
                break;
            }

            canvasGroup.gameObject.SetActive(true);
            yield return(_instance.StartCoroutine(_instance.Fade(1f, canvasGroup)));
        }
示例#23
0
 public void FadeOut(FadeType type, float duration = 1.5f)
 {
     this.m_FadeDuration = duration;
     Debug.Log(string.Concat(new string[]
     {
         "FadeSystem FadOut m_FadeIn = ",
         this.m_FadeIn.ToString(),
         " m_FadeOut = ",
         this.m_FadeOut.ToString(),
         " m_FadingIn ",
         this.m_FadingIn.ToString(),
         " m_FadingOut ",
         this.m_FadingOut.ToString()
     }));
     this.m_FadeType      = type;
     this.m_FadeOut       = true;
     this.m_FadeIn        = false;
     this.m_FadingIn      = false;
     this.m_FadeLevel1[0] = 0f;
     this.m_FadeLevel1[1] = 0f;
     this.m_Active        = true;
 }
示例#24
0
 // Update is called once per frame
 void Update()
 {
     if (fadeType == FadeType.FadeOut)
     {
         alpha_prm += Time.deltaTime * 1.2f;
         if (alpha_prm >= fadeSpeed)
         {
             fadeType = FadeType.FadeNone;
         }
         SetAlpha(Mathf.Min(alpha_prm / fadeSpeed));
     }
     if (fadeType == FadeType.FadeIn)
     {
         alpha_prm -= Time.deltaTime;
         if (alpha_prm <= 0)
         {
             fadeType          = FadeType.FadeNone;
             renderer1.enabled = false;
         }
         SetAlpha(Mathf.Max(0, alpha_prm / fadeSpeed));
     }
 }
示例#25
0
        //
        public void StartFade(FadeType fadeType, float timeMS, bool destroyAtEnd)
        {
            if (fadeType == FadeType.FadeIn)
            {
                m_fadeOpacity = m_opacity;
                m_fadeSign    = -1;
            }
            else
            {
                m_fadeOpacity = 0;
                m_fadeSign    = 1;
            }

            m_fadeTimerMS = new Timer(Engine.RealTime.Source, timeMS);

            if (destroyAtEnd)
            {
                m_fadeTimerMS.OnTime += m_fadeTimer_OnTime;
            }

            m_fadeTimerMS.Start();
        }
示例#26
0
 public static void Play(string _title)
 {
     if (!Controller)
     {
         return;
     }
     if (CurrentTitle == _title)
     {
         return;
     }
     BGM.Stop();
     Fade = FadeType.NONE;
     if (Loops.ContainsKey(_title))
     {
         LoopStats = Loops[_title];
     }
     BGM.volume      = MaxBGMVolume;
     BGM.clip        = (AudioClip)Resources.Load("BGM/" + _title);
     BGM.timeSamples = 0;
     BGM.Play();
     CurrentTitle = _title;
 }
示例#27
0
    // Update is called once per frame
    void Update()
    {
        /*
         * if( vrFade != null )
         * {
         *  return ;
         * }
         */

        bool bFinish = false;

        switch (fadeType)
        {
        case FadeType.FADE_IN:
            bFinish = FadeIn();
            break;

        case FadeType.FADE_OUT:
            bFinish = FadeOut();
            break;
        }

        // フェードカウンター
        if (IsFade())
        {
            counter += GameDefine.FPSDeltaScale();

            if ((int)counter > FadeTime)
            {
                counter = FadeTime;
                if (bFinish)
                {
                    Debug.Log("Fade" + fadeType + "Is Finish");
                    fadeType = FadeType.FADE_NONE;
                    counter  = 0.0f;
                }
            }
        }
    }
示例#28
0
        override public void ShowGUI()
        {
            fadeType = (FadeType)EditorGUILayout.EnumPopup("Type:", fadeType);

            if (fadeType == FadeType.fadeOut)
            {
                setTexture = EditorGUILayout.Toggle("Custom fade texture?", setTexture);
                if (setTexture)
                {
                    tempTexture = (Texture2D)EditorGUILayout.ObjectField("Fade texture:", tempTexture, typeof(Texture2D), false);
                }
            }

            isInstant = EditorGUILayout.Toggle("Instant?", isInstant);
            if (!isInstant)
            {
                fadeSpeed = EditorGUILayout.Slider("Time to fade:", fadeSpeed, 0, 3);
                willWait  = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
示例#29
0
 // Update is called once per frame
 void Update()
 {
     if (fadeType_ == FadeType.FT_FadeIn)
     {
         progress += Time.deltaTime;
         if (progress >= 1f)
         {
             if (isPlaying_)
             {
                 EnterSenseMode();
             }
             else
             {
                 QuitSenseMode();
             }
             fadeType_ = FadeType.FT_FadeOut;
             progress  = 1f;
         }
     }
     else if (fadeType_ == FadeType.FT_FadeOut)
     {
         progress -= Time.deltaTime;
         if (progress <= 0f)
         {
             if (isPlaying_ == false)
             {
                 ProcEventForGuide();
             }
             progress  = 0f;
             fadeType_ = FadeType.FT_None;
             ApplicationEntry.Instance.switchSceneMask_.SetActive(false);
         }
     }
     else
     {
         progress = 0f;
     }
 }
示例#30
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            fadeType = (FadeType)EditorGUILayout.EnumPopup("Type:", fadeType);

            if (fadeType == FadeType.fadeOut)
            {
                setTexture = EditorGUILayout.Toggle("Custom fade texture?", setTexture);
                if (setTexture)
                {
                    tempTextureParameterID = Action.ChooseParameterGUI("Fade texture:", parameters, tempTextureParameterID, ParameterType.UnityObject);
                    if (tempTextureParameterID < 0)
                    {
                        tempTexture = (Texture2D)EditorGUILayout.ObjectField("Fade texture:", tempTexture, typeof(Texture2D), false);
                    }
                }
            }

            isInstant = EditorGUILayout.Toggle("Instant?", isInstant);
            if (!isInstant)
            {
                fadeSpeedParameterID = Action.ChooseParameterGUI("Time to fade (s):", parameters, fadeSpeedParameterID, ParameterType.Float);
                if (fadeSpeedParameterID < 0)
                {
                    fadeSpeed = EditorGUILayout.Slider("Time to fade (s):", fadeSpeed, 0f, 10f);
                }

                forceCompleteTransition = EditorGUILayout.Toggle("Force complete transition?", forceCompleteTransition);
                if (forceCompleteTransition)
                {
                    fadeCurve = (AnimationCurve)EditorGUILayout.CurveField("Transition curve:", fadeCurve);
                }
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            cameraFadePauseBehaviour = (CameraFadePauseBehaviour)EditorGUILayout.EnumPopup("Behaviour when paused:", cameraFadePauseBehaviour);

            AfterRunningOption();
        }
示例#31
0
    public static void CrossFadeBGM(string _title)
    {
        if (!Controller)
        {
            return;
        }
        if (CurrentTitle == _title)
        {
            return;
        }
        AudioClip c = (AudioClip)Resources.Load("BGM/" + _title);

        if (c != null)
        {
            CurrentTitle = _title;
            LoopStats    = Loops[_title];
            Fade         = FadeType.FADEINOUT;
            Crossfade.Stop();
            Crossfade.clip   = c;
            Crossfade.volume = 0;
            Crossfade.Play();
        }
    }
示例#32
0
        public static void Update()
        {
            if (sCurrentAction == FadeType.In)
            {
                sFadeAmt -= (Globals.System.GetTimeMs() - sLastUpdate) / sFadeRate * 255f;
                if (sFadeAmt <= 0f)
                {
                    sCurrentAction = FadeType.None;
                    sFadeAmt       = 0f;
                }
            }
            else if (sCurrentAction == FadeType.Out)
            {
                sFadeAmt += (Globals.System.GetTimeMs() - sLastUpdate) / sFadeRate * 255f;
                if (sFadeAmt >= 255f)
                {
                    sCurrentAction = FadeType.None;
                    sFadeAmt       = 255f;
                }
            }

            sLastUpdate = Globals.System.GetTimeMs();
        }
示例#33
0
        private IEnumerator DoTheFadingAndTheQuitting(FadeType texture = FadeType.BLACK, bool slowMo = true)
        {
            if (slowMo)
            {
                //slowmotion
                fadeSpeed *= 0.1f;
            }

            //does the fading
            yield return(new WaitForSeconds(BeginFade(1, texture)));

            //and also the quitting
                        #if UNITY_WEBGL || UNITY_EDITOR
            if (slowMo)
            {
                fadeSpeed *= 10;                 //undo slowmo if it was enabled
            }
            SceneManager.LoadScene(0);
                        #else
            Time.timeScale = 0;
            Application.Quit(0);
                        #endif
        }
示例#34
0
    public void SetFadeType(FadeType f)
    {
        fadeType = f;
        switch (f)
        {
        case FadeType.FADEIN:
            isFadeInFinished  = false;
            isFadeOutFinished = false;
            fadeInTime        = 0.0f;
            fadeOutTime       = 0.0f;
            break;

        case FadeType.FADEOUT:
            isFadeInFinished  = false;
            isFadeOutFinished = false;
            fadeInTime        = 0.0f;
            fadeOutTime       = 0.0f;
            break;

        default:
            break;
        }
    }
示例#35
0
        //Corutina estatica FadeOut, el mimso se pasa su propio parametro fadeType, interesnate...
        public static IEnumerator FadeSceneOut(FadeType fadeType = FadeType.Black)
        {   //.Black y .Gameover es llamado desde playerChar.. cuadndo muere
            CanvasGroup canvasGroup;

            switch (fadeType)
            {
            case FadeType.Black:
                canvasGroup = Instance.faderCanvasGroup;
                break;

            case FadeType.GameOver:
                canvasGroup = Instance.gameOverCanvasGroup;
                break;

            default:
                canvasGroup = Instance.loadingCanvasGroup;
                break;
            }

            canvasGroup.gameObject.SetActive(true);
            //Usa dos veces Instance por que esta anidando corutinas la primera para ejecutar StartCoroutine dentro de FadeScen..estitco y Fade que no es estatico
            yield return(Instance.StartCoroutine(Instance.Fade(1f, canvasGroup)));
        }
示例#36
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            parameterID = Action.ChooseParameterGUI("Sprite to fade:", parameters, parameterID, ParameterType.GameObject);
            if (parameterID >= 0)
            {
                constantID  = 0;
                spriteFader = null;
            }
            else
            {
                spriteFader = (SpriteFader)EditorGUILayout.ObjectField("Sprite to fade:", spriteFader, typeof(SpriteFader), true);

                constantID  = FieldToID <SpriteFader> (spriteFader, constantID);
                spriteFader = IDToField <SpriteFader> (spriteFader, constantID, false);
            }

            fadeType = (FadeType)EditorGUILayout.EnumPopup("Type:", fadeType);

            fadeSpeed = EditorGUILayout.Slider("Time to fade:", fadeSpeed, 0f, 10f);
            willWait  = EditorGUILayout.Toggle("Wait until finish?", willWait);

            AfterRunningOption();
        }
示例#37
0
        public static IEnumerator FadeSceneOut(FadeType fadeType = FadeType.Black)
        {
            CanvasGroup canvasGroup;

            switch (fadeType)
            {
            case FadeType.Black:
                canvasGroup = Instance.faderCanvasGroup;
                break;

            case FadeType.GameOver:
                canvasGroup = Instance.gameOverCanvasGroup;
                break;

            default:
                canvasGroup = Instance.loadingCanvasGroup;
                break;
            }

            canvasGroup.gameObject.SetActive(true);

            yield return(Instance.StartCoroutine(Instance.Fade(1f, canvasGroup)));
        }
示例#38
0
    private IEnumerator FadeCoroutine(AnimationCurve curve, FadeType type)
    {
        OnTransitionStart(type);
        Transitioning = true;

        AnimationCurveHelper.ChangeFirstKeyframeValue(curve, Value);
        AnimationCurveHelper.ChangeLastKeyframeTime(curve, Duration);

        float endTime     = Duration;
        float elapsedTime = 0;

        while (elapsedTime <= endTime)
        {
            Value = curve.Evaluate(elapsedTime);

            elapsedTime += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        Value         = AnimationCurveHelper.LastKey(curve).value;
        Transitioning = false;
        OnTransitionStop(type);
    }
示例#39
0
 // Update is called once per frame
 void Update()
 {
     if (fadeType == FadeType.fadeout)
     {
         if (duration == 0)
         {
             cg.alpha = 0;
             fadeType = FadeType.none;
         }
         else
         {
             cg.alpha    = Mathf.Lerp(1, 0, timePassed);
             timePassed += Time.deltaTime * (1 / duration);
             if (cg.alpha == 0)
             {
                 fadeType = FadeType.none;
             }
         }
     }
     if (fadeType == FadeType.fadein)
     {
         if (duration == 0)
         {
             cg.alpha = 1;
             fadeType = FadeType.none;
         }
         else
         {
             cg.alpha    = Mathf.Lerp(0, 1, timePassed);
             timePassed += Time.deltaTime * (1 / duration);
             if (cg.alpha == 1)
             {
                 fadeType = FadeType.none;
             }
         }
     }
 }
    //-----------------------------------------------------------------------------
    // OnGUI
    //-----------------------------------------------------------------------------

//	void OnGUI(){
//		//draw buttons:
//		DrawFadeButton();
//		DrawCameraFlashButton();
//		DrawInjuryButton();
//	}

    //-----------------------------------------------------------------------------
    // Private Methods
    //-----------------------------------------------------------------------------

    void DrawFadeButton()
    {
        //decide text to display on the button based on state of fadeDirection:
        string fadeText = fadeDirection ? "down" : "up";

        if (GUILayout.Button("Fade " + fadeText))
        {
            //set type of fadeDirection:
            currentFadeType = FadeType.Fade;

            //toggle state of fadeDirection:
            fadeDirection = !fadeDirection;

            //fade up or down based on state of fadeDirection:
            if (fadeDirection)
            {
                ScreenFade.Fade(Color.black, ScreenFade.CurrentAlpha, 1, 1, 0, false);
            }
            else
            {
                ScreenFade.Fade(Color.black, ScreenFade.CurrentAlpha, 0, 1, 0, false);
            }
        }
    }
示例#41
0
 public Fade(Player Player, int TargetVolume, int Length, FadeType Type)
 {
     if (!Player.CanFade) { return; }
     if (Type == FadeType.VolumeChange && Player._Fade != null && Player._Fade.Type != FadeType.VolumeChange)
     {
         return;
     }
     this._Player = Player;
     int Position = Player.Position;
     this._StartPosition = Position;
     this._EndPosition = Position + (int)Length;
     this._StartVolume = Player.RealVolume;
     this._EndVolume = TargetVolume;
     this._Type = Type;
     Player._Fade = this;
     if (!Fade.Enabled) { this.Finish(); }
 }
示例#42
0
 public FinalFade(Player Player, int Length, FadeType Type)
     : base(Player, 0, Length, Type)
 {
     if (!Player.CanFade) { return; }
     if (Player.Paused) { this.Finish(); }
     Player.FadeStarted(Player, new EventArgs());
 }
示例#43
0
 public void FadeOut(float time, bool resetIfOut, FadeType fadeType, float pow)
 {
     if (resetIfOut) {
         if (FadeLevel < 0.01f) FadeLevel = 1f;
     }
     Fade (time, FadeLevel, 0f, fadeType, pow);
 }
示例#44
0
        protected override bool ReadRealWorldParameters()
        {
            if (PluginName == "SSLComp") {

                // <Parameters Type="RealWorld">8 1 * 3 4 3 * 1 1 1
                // 0 0 0.95000000000000006661 1 0.95000000000000006661 </Parameters>

                // split the parameters text into sections
                string[] splittedPhrase = RealWorldParameters.Split(' ', '\n');

                //Threshold (-15 - +15)
                Threshold = float.Parse(splittedPhrase[0], CultureInfo.InvariantCulture); // compression threshold in dB

                //Ratio (2:1=0, 4:1=1, 10:1=2)
                Ratio = (RatioType) Enum.Parse(typeof(RatioType), splittedPhrase[1]);

                // Fade [Off=0 or *, Out=1, In=2]
                if (splittedPhrase[2] != "*") {
                    Fade = (FadeType) Enum.Parse(typeof(FadeType), splittedPhrase[2]);
                } else {
                    Fade = FadeType.Off;
                }

                // Attack [0 - 5, .1 ms, .3 ms, 1 ms, 3 ms, 10 ms, 30 ms)
                int attack = int.Parse(splittedPhrase[3]);
                switch(attack) {
                    case 0:
                        Attack = 0.1f;
                        break;
                    case 1:
                        Attack = 0.3f;
                        break;
                    case 2:
                        Attack = 1.0f;
                        break;
                    case 3:
                        Attack = 3.0f;
                        break;
                    case 4:
                        Attack = 10.0f;
                        break;
                    case 5:
                        Attack = 30.0f;
                        break;
                }

                // Release: 0 - 4, .1 s, .3 s, .6 s, 1.2 s, Auto (-1)
                int release = int.Parse(splittedPhrase[4]);
                switch(release) {
                    case 0:
                        Release = 0.1f;
                        break;
                    case 1:
                        Release = 0.3f;
                        break;
                    case 2:
                        Release = 0.6f;
                        break;
                    case 3:
                        Release = 1.2f;
                        break;
                    case 4:
                        Release = -1.0f;
                        break;
                }

                //Make-Up Gain (-5 - +15) dB
                MakeupGain = float.Parse(splittedPhrase[5], CultureInfo.InvariantCulture);

                //*
                string Delimiter1 = splittedPhrase[6];

                //Rate-S (1 - +60) seconds
                // Autofade duration. Variable from 1 to 60 seconds
                RateS = float.Parse(splittedPhrase[7], CultureInfo.InvariantCulture);

                //In
                In = (splittedPhrase[8] == "1");

                //Analog
                Analog = (splittedPhrase[9] == "1");

                return true;
            } else {
                return false;
            }
        }
示例#45
0
 public void PlayFadeOut()
 {
     fadeType = FadeType.FADEOUT;
     Reset();
     isActive = true;
 }
示例#46
0
        /**
         * <summary>Fades the camera out.</summary>
         * <param name = "_timeToFade">The duration, in seconds, of the fade effect</param>
         */
        public void FadeOut(float _timeToFade)
        {
            AssignFadeTexture ();

            if (alpha == 0f)
            {
                alpha = 0.01f;
            }
            if (_timeToFade > 0f)
            {
                alpha = Mathf.Clamp01 (alpha);
                timeToFade = _timeToFade;
                fadeType = FadeType.fadeOut;
                fadeStartTime = Time.time - (alpha * timeToFade);
            }
            else
            {
                alpha = 1f;
                timeToFade = 0f;
            }
        }
示例#47
0
        /**
         * <summary>Fades the camera in.</summary>
         * <param name = "_timeToFade">The duration, in seconds, of the fade effect</param>
         * <param name = "forceCompleteTransition">If True, the camera will be faded out instantly before beginning</param>
         */
        public void FadeIn(float _timeToFade, bool forceCompleteTransition = true)
        {
            AssignFadeTexture ();

            if ((forceCompleteTransition || alpha > 0f) && _timeToFade > 0f)
            {
                if (forceCompleteTransition)
                {
                    alpha = 1f;
                    fadeStartTime = Time.time;
                }
                else
                {
                    fadeStartTime = Time.time - (_timeToFade * (1f - alpha));
                }
                timeToFade = _timeToFade;
                fadeType = FadeType.fadeIn;
            }
            else
            {
                alpha = 0f;
                timeToFade = 0f;
                ReleaseFadeTexture ();
            }
        }
示例#48
0
 /// <summary>
 /// Fade from one value to another.
 /// </summary>
 public void Fade(float time, float start, float end, FadeType fadeType, float pow)
 {
     int position = AddFading ();
     CancelAllOtherFading (position);
     Fader.Instance.Fade (this, time, start, end, position, fadeType, pow);
 }
示例#49
0
    private IEnumerator CoFade(Fadeable f, float time, float start, float end, int fadingPosition, FadeType fadeType, float pow)
    {
        if (time == 0) yield break;
        float eTime = 0f;
        f.fading[fadingPosition] = true;
        f.FadeLevel = start;

        while (eTime < time && f.fading[fadingPosition]) {
            eTime += Time.deltaTime;
            switch (fadeType) {
                case FadeType.Lin:
                    f.FadeLevel = Mathf.Lerp (start, end, eTime / time);
                    break;
                case FadeType.Exp:
                    f.FadeLevel = MathfExtended.SteepErp (start, end, pow, eTime / time);
                    break;
                case FadeType.Log:
                    f.FadeLevel = MathfExtended.ShallowErp (start, end, pow, eTime / time);
                    break;
            }
            yield return 0;
        }

        if (f.fading[fadingPosition]) {
            f.FadeLevel = end;
            f.fading[fadingPosition] = false;
        }
    }
示例#50
0
 public void Fade(Fadeable f, float time, float start, float end, int fadingPosition, FadeType fadeType, float pow)
 {
     StartCoroutine (CoFade (f, time, start, end, fadingPosition, fadeType, pow));
 }
示例#51
0
 public void FadeTo(float time, float end, FadeType fadeType, float pow)
 {
     Fade (time, FadeLevel, end, fadeType, pow);
 }
	void DrawInjuryButton(){
		if ( GUILayout.Button( "Injury" ) ) {
			fadeDirection = false;
			currentFadeType = FadeType.Injury;
			ScreenFade.Fade( Color.red, .6f, 0, .35f, 0, true );
			cachedAudioSource.pitch = Random.Range ( .99f, 1.1f );
			PlaySound( injurySound, .1f );
		}
	}
示例#53
0
        /**
         * <summary>Fades the camera in.</summary>
         * <param name = "_timeToFade">The duration, in seconds, of the fade effect</param>
         */
        public void FadeIn(float _timeToFade)
        {
            AssignFadeTexture ();

            if (_timeToFade > 0f)
            {
                timeToFade = _timeToFade;
                alpha = 1f;
                fadeType = FadeType.fadeIn;
                fadeStartTime = Time.time;
            }
            else
            {
                alpha = 0f;
                timeToFade = 0f;
                ReleaseFadeTexture ();
            }
        }
示例#54
0
        /**
         * <summary>Fades the camera out.</summary>
         * <param name = "_timeToFade">The duration, in seconds, of the fade effect</param>
         * <param name = "forceCompleteTransition">If True, the camera will be faded in instantly before beginning</param>
         */
        public void FadeOut(float _timeToFade, bool forceCompleteTransition = true)
        {
            AssignFadeTexture ();

            if (alpha == 0f)
            {
                alpha = 0.01f;
            }
            if ((forceCompleteTransition || alpha < 1f) && _timeToFade > 0f)
            {
                if (forceCompleteTransition)
                {
                    alpha = 0.01f;
                    fadeStartTime = Time.time;
                }
                else
                {
                    alpha = Mathf.Clamp01 (alpha);
                    fadeStartTime = Time.time - (alpha * timeToFade);
                }
                timeToFade = _timeToFade;
                fadeType = FadeType.fadeOut;
            }
            else
            {
                alpha = 1f;
                timeToFade = 0f;
            }
        }
示例#55
0
 public void PlayFadeIn()
 {
     fadeType = FadeType.FADEIN;
     Reset();
     isActive = true;
 }
示例#56
0
 public StopSettings(Metronome metronome, SnapStyle snapStyle, float beat, float delay, float fadeLength, FadeType fadeType, float power)
     : this(true, metronome, snapStyle, beat, delay, fadeLength, fadeType, power)
 {
 }
示例#57
0
 public void FadeIn(float time, bool resetIfIn, FadeType fadeType, float pow)
 {
     if (resetIfIn) {
         if (FadeLevel > 0.99f) FadeLevel = 0f;
     }
     Fade (time, FadeLevel, 1f, fadeType, pow);
 }
示例#58
0
        public float updateTime = 0.25f; // We call Decay() every updateTime seconds

        #endregion Fields

        #region Constructors

        public Settings(bool autoDecay, float decayTime, FadeType decayCurve, float power)
        {
            this.autoDecay = autoDecay;
            this.decayTime = decayTime;
            this.decayCurve = decayCurve;
            this.power = power;
        }
示例#59
0
 protected void SetFinalFade(Player Player, int Length, FadeType Type)
 {
     new FinalFade(Player, Length, Type);
 }
示例#60
0
 public void FadeOut(float time, FadeType fadeType, float pow)
 {
     FadeOut (time, true, fadeType, pow);
 }