Access Fade from script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Access Fade from script

Post by xyztankman »

Is there a quick command to fade from script? I am currently trying to fade out when loading a scene (I'm actually putting the fade command in a coroutine instead of the function but that's not in the screenshot) but I get this error when attempting to use SaveSystem.sceneTRansitionManager.FadeOut()
Attachments
Fade.PNG
Fade.PNG (23.48 KiB) Viewed 13238 times
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access Fade from script

Post by Tony Li »

Hi,

Is there a reason why you're not just using SaveSystem.LoadScene() to change scenes? It handles the scene transition manager automatically:

Code: Select all

SaveSystem.LoadScene("your-scene-name");
If you want to manually fade out, you can run its LeaveScene() coroutine:

Code: Select all

StartCoroutine(SaveSystem.sceneTransitionManager.LeaveScene());
Or you can use a reference to the scene transition manager's animator and set its Show trigger:

Code: Select all

SaveSystem.sceneTransitionManager.leaveSceneTransition.animator.SetTrigger("Show");
(Assuming you're using the default SceneFaderCanvas animator or something similar.)
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Re: Access Fade from script

Post by xyztankman »

I was actually using only

PixelCrushers.SaveSystem.LoadScene("SceneMainMenu");

previously but it seems the fade stopped working for some reason. could it be because I don't have a SceneFaderCanvas in the prefab of the dialogue manager? I opened an empty project and imported the latest dialogue manager from the asset store and didn't see a SceneFaderCanvas listed on the dialogue manager either.

I was able to fade by using a dialogue trigger and setting a fade in the sequence while executing a couple functions for scene change but the coroutine method did not work as well.
Attachments
Fade2.PNG
Fade2.PNG (49.72 KiB) Viewed 13226 times
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access Fade from script

Post by Tony Li »

Hi,

The base Dialogue Manager prefab doesn't have a SceneFaderCanvas since not project will use the save system or change scenes. The Dialogue Manager prefab variant used in the Demo does have a SceneFaderCanvas. There's also a separate SaveSystemPrefabs package (direct download) on the Dialogue System Extras page that comes with a fully configured Save System prefab and other useful prefabs.
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Re: Access Fade from script

Post by xyztankman »

Thanks Tony, I grabbed it from there, I was sure I saw it somewhere but forgot it was in the demo! Got it configured and it's looking great, also easy way to use my own loading screen if I wanted.
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access Fade from script

Post by Tony Li »

Awesome! Glad to help.
Post Reply