Пример #1
0
    // Since the load function requires a coroutine, it's nice to have a wrapper
    // like this to just call. We could probably do the bundle and get the current
    // scene ref inside the coroutine, but this is fine.
    public static void LoadScene(string sceneName)
    {
        // Ensure scene is already bundled properly.
        BundleScene(SceneManager.GetActiveScene().name);

        // Get scene ref.
        Scene current = SceneManager.GetActiveScene();

        // Ensure selfRef exists.
        EnsureRefExists();

        // If the scene is already loaded, just switch to it.
        if (loadedScenes.ContainsKey(sceneName))
        {
            Debug.Log("Scene already loaded, going back to that one.");
            selfRef.StartCoroutine(Switcher(sceneName));
        }
        else
        {
            // Load the scene we are trying to merge.
            selfRef.StartCoroutine(Loader(sceneName, current));
        }
    }