Ejemplo n.º 1
0
    private void SpawnTransitionObjects(bool firstTime)
    {
        // No transition object to spawn
        if (!faderPrefab)
        {
            return;
        }

        // Set a reference to this scene's transition object
        fader = Instantiate(faderPrefab);
        // Position it to cover the screen
        fader.transform.SetParent(FindObjectOfType <Canvas>().transform);
        fader.GetComponent <RectTransform>().offsetMin = Vector2.zero;
        fader.GetComponent <RectTransform>().offsetMax = Vector2.zero;
        fader.transform.localScale = Vector2.one;

        // Since we are calling this at the OnSceneLoaded event, we must be fading in to the scene
        fader.SetTransitionState(TransitionState.FadingIn);
        if (!firstTime)
        {
            fader.opacity = 1;

            fader.PlayTransitionSound();
        }
        else         // No need to play a transition when we press the play button
        {
            fader.opacity = 0;
        }
    }
Ejemplo n.º 2
0
    public IEnumerator LoadSceneCoroutine()
    {
        // Setup transition object
        fader.SetTransitionState(TransitionState.FadingOut);
        fader.PlayTransitionSound();

        // Wait for transition to finish
        yield return(new WaitForSeconds(fader.transitionTime));

        SceneManager.LoadScene(sceneToLoad);
    }