コード例 #1
0
        public IEnumerator IE_DoTransition( E_TransitionType type, float delay, float duration = -1f, System.Action callback = null )
        {
            //  Delay
            yield return new WaitForSeconds ( delay );

            //  Decide if use component or param duration
            duration = duration == -1f ? _transitionDuration : duration;

            float i;
            switch ( type )
            {
                case E_TransitionType.Show:

                    //  Set to 0
                    i = 0f;
                    _renderer.material.SetFloat ( CUTOFF, i );

                    //  Tween param
                    DOTween.To ( ( ) => i, x => i = x, 1, duration ).SetEase ( _ease );

                    //  Do transition
                    while ( _renderer.material.GetFloat ( CUTOFF ) < 1f )
                    {
                        _renderer.material.SetFloat ( CUTOFF, i );
                        yield return null;
                    }

                    //  Callback
                    if ( callback != null ) callback ( );
                    if ( OnTransitionEnded != null ) OnTransitionEnded ( );

                    break;

                case E_TransitionType.Hide:

                    //  Set to 1
                    i = 1f;
                    _renderer.material.SetFloat ( CUTOFF, i );

                    //  Tween param
                    DOTween.To ( ( ) => i, x => i = x, 0, duration ).SetEase ( _ease );

                    //  Do transition
                    while ( _renderer.material.GetFloat ( CUTOFF ) > 0f )
                    {
                        _renderer.material.SetFloat ( CUTOFF, i );
                        yield return null;
                    }

                    //  Callback
                    if ( callback != null ) callback ( );
                    if ( OnTransitionEnded != null ) OnTransitionEnded ( );

                    break;
            }
        }
コード例 #2
0
 public void DoTransition( E_TransitionType type, float delay, float duration = -1, System.Action callback = null )
 {
     StartCoroutine ( IE_DoTransition ( type, delay, duration, callback ) );
 }