Exemplo n.º 1
0
    private IEnumerator ILoadScene(SceneIndexes sceneBuildIndex, int animationIndex = 0)
    {
        Animator anim  = _animators[animationIndex];
        float    timer = 0;
        float    minimumTransitionTime = 0;

        AnimationClip[] animationClips = anim.runtimeAnimatorController.animationClips;

        for (int i = 0; i < animationClips.Length - 1; i++) // skip the last animation
        {
            minimumTransitionTime += animationClips[i].length;
        }

        // Start animation
        anim.SetTrigger("Start");

        AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync(sceneBuildIndex.ToString(), LoadSceneMode.Single);

        asyncLoadLevel.allowSceneActivation = false;


        while (!asyncLoadLevel.isDone)
        {
            // only allows a scene change if the first part of the transition has been completed
            timer += Time.deltaTime;
            if (timer > minimumTransitionTime)
            {
                asyncLoadLevel.allowSceneActivation = true;
            }

            yield return(null);
        }

        anim.SetTrigger("End");
    }
Exemplo n.º 2
0
 public void OnPointerDown(PointerEventData eventData)
 {
     if (parent.Open)
     {
         if (SceneManager.GetActiveScene().name == scene.ToString())
         {
             parent.OpenClose();
         }
         else if (SceneHandler.Instance.LoadScene(scene))
         {
             parent.OnTransition();
         }
     }
 }
Exemplo n.º 3
0
    public bool LoadScene(SceneIndexes sceneBuildIndex, int animationIndex = 0)
    {
        if (SceneManager.GetActiveScene().name != sceneBuildIndex.ToString() &&
            animationIndex >= 0 && animationIndex < _animators.Length)
        {
            StartCoroutine(ILoadScene(sceneBuildIndex, animationIndex));
            return(true);
        }

        else
        {
            Debug.LogWarning("Trying to load identical scene or reach a scene that does not exist!", this);
            return(false);
        }
    }