[HOWTO] How To Use Different Loading Screens With Scene Transition Manager

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22166
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To Use Different Loading Screens With Scene Transition Manager

Post by Tony Li »

Pixel Crushers assets share a save system.

This save system can use an optional scene transition manager -- for example, to fade out the old scene, optionally show an intermediate loading scene, and then fade in the new scene. The scene transition manager should be on the same GameObject as the Save System component, which means it survives scene changes, allowing it to manage the transition from the old scene to the new scene.

SceneTransitionManager is an abstract class; you can implement it however you like. The default implementation is called StandardSceneTransitionManager. On your StandardSceneTransitionManager, you can set a single optional loading scene name.

If you want to change the loading scene on a per-scene basis, or even select a random loading scene, you can add a script like this to each scene:
SetRandomLoadingScreen.cs

Code: Select all

using UnityEngine;
using PixelCrushers;

public class SetRandomLoadingScreen : MonoBehaviour
{
    public string[] loadingSceneNames; //<-- Set scene names in inspector.
    
    private void Start()
    {
        string loadingSceneName = loadingSceneNames[Random.Range(0, loadingSceneNames.Length)];
        (SaveSystem.sceneTransitionManager as StandardSceneTransitionManager).loadingSceneName = loadingSceneName;
    }
}
If you want more control, the methods in StandardSceneTransitionManager are virtual, so you can override them to do whatever you want.
Post Reply