IEnumerator TransitionParallel(GameObject fromGameObject, GameObject toGameObject)
        {
            float transitionOutTime = 0;

            if (fromGameObject != null)
            {
                if (TransitionHelper.ContainsTransition(fromGameObject))
                {
                    var transitions = TransitionHelper.TransitionOut(fromGameObject);
                    transitionOutTime = TransitionHelper.GetTransitionOutTime(transitions);
                }
            }
            if (toGameObject != null)
            {
                toGameObject.SetActive(true);
                if (TransitionHelper.ContainsTransition(toGameObject))
                {
                    TransitionHelper.TransitionIn(toGameObject);
                }
            }

            // wait for transition out to complete before we disable.
            if (!Mathf.Approximately(0, transitionOutTime))
            {
                yield return(new WaitForSeconds(transitionOutTime));
            }

            if (fromGameObject != null)
            {
                fromGameObject.SetActive(false);
            }
        }
Esempio n. 2
0
 IEnumerator TransitionOutIn(GameObject oldGameObject, GameObject newGameObject)
 {
     if (oldGameObject != null)
     {
         if (TransitionHelper.ContainsTransition(oldGameObject))
         {
             var transitions = TransitionHelper.TransitionOut(oldGameObject);
             yield return(new WaitForSeconds(TransitionHelper.GetTransitionOutTime(transitions)));
         }
         oldGameObject.SetActive(false);
     }
     newGameObject.SetActive(true);
 }
 IEnumerator TransitionOutIn(GameObject fromGameObject, GameObject toGameObject)
 {
     if (fromGameObject != null)
     {
         // is an out transition then run and wait for completion
         if (TransitionHelper.ContainsTransition(fromGameObject))
         {
             var transitions       = TransitionHelper.TransitionOut(fromGameObject);
             var transitionOutTime = TransitionHelper.GetTransitionOutTime(transitions);
             yield return(new WaitForSeconds(transitionOutTime));
         }
         fromGameObject.SetActive(false);
     }
     if (toGameObject != null)
     {
         toGameObject.SetActive(true);
         if (TransitionHelper.ContainsTransition(toGameObject))
         {
             TransitionHelper.TransitionIn(toGameObject);
         }
     }
 }