Scenes transition

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
qest43
Posts: 33
Joined: Thu May 26, 2022 9:22 am

Scenes transition

Post by qest43 »

Hello, so I tried to apply today scenes transition via Scene Portal Script and it works great, also with Scene Fader. But how can I also use it when I start game in Main Menu and click New Game, how can I use this transition function with fader in this case?
User avatar
Tony Li
Posts: 21972
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scenes transition

Post by Tony Li »

Hi,

When you click New Game, does it load a different scene? Or is it still in the main menu scene?

If it's in the main menu scene, you can manually trigger the SceneFaderCanvas's animation states (Show and Hide).

If New Game loads a different scene, make sure to load the scene using any of these techniques. They will use the StandardSceneTransitionManager.
qest43
Posts: 33
Joined: Thu May 26, 2022 9:22 am

Re: Scenes transition

Post by qest43 »

New Game loads a different scene in my case, and I already added

Code: Select all

            PixelCrushers.SaveSystem.LoadScene("Area 0");
            GameMenu.Open();
to my script and it works. But previously I was using:

Code: Select all

        private IEnumerator OnPlayPressedRoutine()
        {
            TransitionFader.PlayTransition(startTransitionPrefab);
            yield return new WaitForSeconds(_playDelay);
            Game.LevelLoader.Instance.LoadLevelAsync(1);
            GameMenu.Open();
        }
And now I have problem, because GameMenu was opening after screen fades out, but now it turns on immediately, and I dont know how to use yield or another solution in that case.
User avatar
Tony Li
Posts: 21972
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scenes transition

Post by Tony Li »

Hi,

There are a few ways to do that. Here are some of them:

- You can add a script to your "Area 0" scene. In the script's Start() method, call GameMenu.Open().

- Or hook into the PixelCrushers.SaveSystem.sceneLoaded event:

Code: Select all

SaveSystem.sceneLoaded += OnSceneLoaded;

void OnSceneLoaded(string sceneName, int sceneIndex)
{
    SaveSystem.sceneLoaded -= OnSceneLoaded;
    GameMenu.Open();
}
qest43
Posts: 33
Joined: Thu May 26, 2022 9:22 am

Re: Scenes transition

Post by qest43 »

Yes, second option works perfectly, thank you!
User avatar
Tony Li
Posts: 21972
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scenes transition

Post by Tony Li »

Glad to help!
Post Reply