void load()
    {
        //call the event to swap music NOW
        EasyAudioUtility_SceneManager sm = FindObjectOfType <EasyAudioUtility_SceneManager>();

        if (sm)
        {
            sm.onSceneChange(sceneToLoad);
        }


        //finally load scene
        //SceneManager.LoadScene(sceneToLoad);

#if PIXELCRUSHERS_SAVESYSTEM
        if (sceneToLoad == "MainMenu" || PlayerPrefs.GetInt("slotLoaded_") == -1)
        {
            asyncOperation.allowSceneActivation = true;
        }
        else
        {
            PixelCrushers.SaveSystem.LoadFromSlot(PlayerPrefs.GetInt("slotLoaded_"));
        }
        return;
#endif
        asyncOperation.allowSceneActivation = true;
    }
Exemple #2
0
    void load()
    {
        //call the event to swap music NOW
        EasyAudioUtility_SceneManager sm = FindObjectOfType <EasyAudioUtility_SceneManager>();

        if (sm)
        {
            sm.onSceneChange(sceneToLoad);
        }


        //finally load scene
        SceneManager.LoadScene(sceneToLoad);
    }
    void load()
    {
        //call the event to swap music NOW
        EasyAudioUtility_SceneManager sm = FindObjectOfType <EasyAudioUtility_SceneManager>();

        if (sm)
        {
            sm.onSceneChange(sceneToLoad);
        }


        //finally load scene
        //SceneManager.LoadScene(sceneToLoad);
        asyncOperation.allowSceneActivation = true;
    }
    void init()
    {
        GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;

        RetrieveSceneToLoad();

        //load on the basis of loading bar fill amount
        if (showLoadingBar)
        {
            //init loading bar
            loadingBar.minValue = 0f;
            loadingBar.maxValue = 100f;
            loadingBar.value    = 0f;

            //enable right object
            loadingBar.gameObject.SetActive(true);
            circularIndicator.SetActive(false);
        }
        //else load after circular laod delay
        else
        {
            //  enable right object
            loadingBar.gameObject.SetActive(false);
            circularIndicator.SetActive(true);

            //set anim speed
            circularIndicator.GetComponent <Animator>().speed = circularIndicatorAnimSpeed;
            Invoke("loadScene", circularLoadDelay);
        }

        //lerp the audio source which is playing to 0
        EasyAudioUtility_SceneManager sm = FindObjectOfType <EasyAudioUtility_SceneManager>();

        if (sm)
        {
            sm.FadeVolume(0);
        }

        //if we have specific loading screen for the scene
        foreach (SceneSpecificLoading l in sceneSpecificLoading)
        {
            if (l.sceneName == sceneToLoad)
            {
                //reset the loading screen image
                defaultLoadingScreenImage.color  = Color.white;
                defaultLoadingScreenImage.sprite = l.loadingImage;

                //exit the init code
                return;
            }
        }

        //If we didn't find any specific image, we just continue normally

        //enable loading screen transitions
        if (showImageTransition)
        {
            defaultLoadingScreenImage.color = Color.white;
            //now invoking transitions
            InvokeRepeating("StartImageTransition", 0f, transitionDuration);
        }
        //else set a random image from array to screen image
        else
        {
            //if any image is added
            if (LoadingScreenImages.Length > 0)
            {
                defaultLoadingScreenImage.color  = Color.white;
                defaultLoadingScreenImage.sprite = LoadingScreenImages[Random.Range(0, LoadingScreenImages.Length)];
            }
        }
    }
    void init()
    {
        GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;

        //retrieve what scene to be loaded
        sceneToLoad = PlayerPrefs.GetString("sceneToLoad");
        //if it's null
        if (sceneToLoad == "")
        {
            sceneToLoad = "MainMenu";
        }

        //now loading scene async
        //SceneManager.LoadSceneAsync(sceneToLoad);
        SceneManager.LoadSceneAsync(sceneToLoad).allowSceneActivation = false;

        //load on the basis of loading bar fill amount
        if (showLoadingBar)
        {
            //init loading bar
            loadingBar.minValue = 0f;
            loadingBar.maxValue = 100f;
            loadingBar.value    = 0f;

            //enable right object
            loadingBar.gameObject.SetActive(true);
            circularIndicator.SetActive(false);
        }
        //else load after circular laod delay
        else
        {
            //  enable right object
            loadingBar.gameObject.SetActive(false);
            circularIndicator.SetActive(true);

            //set anim speed
            circularIndicator.GetComponent <Animator>().speed = circularIndicatorAnimSpeed;
            Invoke("loadScene", circularLoadDelay);
        }

        //enable loading screen transitions
        if (showImageTransition)
        {
            defaultLoadingScreenImage.color = Color.white;
            //now invoking transitions
            InvokeRepeating("StartImageTransition", 0f, transitionDuration);
        }
        //else set a random image from array to screen image
        else
        {
            //if any image is added
            if (LoadingScreenImages.Length > 0)
            {
                defaultLoadingScreenImage.color  = Color.white;
                defaultLoadingScreenImage.sprite = LoadingScreenImages[Random.Range(0, LoadingScreenImages.Length)];
            }
        }

        //lerp the audio source which is playing to 0
        EasyAudioUtility_SceneManager sm = FindObjectOfType <EasyAudioUtility_SceneManager>();

        if (sm)
        {
            sm.FadeVolume(0);
        }
    }