Change Transitions on the Fly for Standard Scene Transition Manager

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Change Transitions on the Fly for Standard Scene Transition Manager

Post by cptscrimshaw »

Hi Tony,

I'd like to be able to change the OnTransitionEnd Unity events when loading a scene on the fly depending on different situations (e.g., loading into a cutscene vs. just loading the scene normally). I was playing around with different options, but figured there's a "best" way to do this. Any thoughts? See the attached screenshot for specificity.

https://ibb.co/yqyC26d

Thanks as always for the fantastic support!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Transitions on the Fly for Standard Scene Transition Manager

Post by Tony Li »

Hi,

The StandardSceneTransitionManager's methods are virtual so you can extend them with your own behavior. For example, say you have a special component CutsceneManager in your cutscene scenes:

Code: Select all

public class CutsceneManager : MonoBehaviour
{
    public void PlayEntryCutscene() { ... }
}
You could override EnterScene() to call its method:

Code: Select all

public class MySceneTransitionManager : StandardSceneTransitionManager
{
    public override IEnumerator EnterScene()
    {
        var cutsceneManager = FindFirstObjectByType<CutsceneManager>();
        if (cutsceneManager != null) cutsceneManager.PlayEntryCutscene();
        yield return base.EnterScene();
    }
}
Then replace your StandardSceneTransitionManager component with your subclass.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Change Transitions on the Fly for Standard Scene Transition Manager

Post by cptscrimshaw »

Worked like a charm! Thanks as always for your excellent, detailed, and superfast support.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Transitions on the Fly for Standard Scene Transition Manager

Post by Tony Li »

Happy to help!
Post Reply