Fade from Black not triggering

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

Re: Fade from Black not triggering

Post by Tony Li »

Hi Rob,

Can you send a reproduction project to tony (at) pixelcrushers.com?

If not, can you try this debug version of StandardSceneTransitionManager.cs?

Debug_StandardSceneTransitionManager_2021-07-08.unitypackage

It will log frame-by-frame animator activity similar to:

Code: Select all

Leave Scene Transition ended on frame 1205
Enter Scene Transition started on frame 1216. Triggering Hide.
Enter Scene Transition frame 1218: state=Fade From Black, progress=0.1220562
Enter Scene Transition frame 1219: state=Fade From Black, progress=0.2312012
...
Enter Scene Transition ended on frame 1423
You may see a frame or two at the beginning of the Enter Scene Transition animation where it's not in the animator state yet, so the progress is off. But then it should start near zero. When it's done, the logs will start showing the Nothing state. Make sure your Standard Scene Transition Manager's Enter Scene Transition > Animation Duration is at least 1 (the duration of the animation clip) for this test.

Other notes:

Your code looks fine. UsePortal() calls SaveSystem.LoadScene(), which starts the coroutine that handles fading and scene loading.

Side note: In a C# script, you don't have to use:

Code: Select all

GetComponent<SaveSystemMethods>().LoadFromSlot(0);
SaveSystemMethods is a wrapper for the SaveSystem class. It's useful to hook into SaveSystem in inspector UnityEvents. In C#, you can call SaveSystem directly:

Code: Select all

SaveSystem.LoadFromSlot(0);
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Fade from Black not triggering

Post by rykaan »

Hi Tony,

I've sent the project through. It'll be in the email via a google drive link. I did add access for the support email address but if something has gone wrong let me know. Oh and cheers for the code tips, I'll make that SaveSystem load change.

Cheers,
Rob
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fade from Black not triggering

Post by Tony Li »

Thanks for sending the reproduction project. I've got it open, and I'll reply back later today.
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fade from Black not triggering

Post by Tony Li »

Hi Rob,

I think I have it figured out. In your StandardSceneTransitionManager setup, Pause During Transition is ticked, and the SceneFaderCanvas's Animator > Update Mode is set to Unscaled Time, which is appropriate if time is paused.

However, especially in the editor's play mode, there's a big frame skip in the first frame. This could be due to Unity or it could be due to slow-running Start()/OnEnable() methods in scripts in your project, or both.

In any case, since the Animator is running in Unscaled Time, it skips ahead because of that big frame skip.

I can suggest two possible solutions:

1. Untick Pause During Transition, and set the Animator's Update Mode to Normal. The Fade From Black animation will be framerate-dependent, so it won't skip ahead in the frame skip.

2. Or insert a dummy state that will take up the slack of the big frame skip:

extraSceneFaderState.png
extraSceneFaderState.png (13.94 KiB) Viewed 536 times

The transition from Any State to Enter Scene checks the Hide trigger.

The transition from Enter Scene (which has no animation clip assigned) to Fade From Black is set to:
  • Has Exit Time: ticked
  • Exit Time: 1
  • Transition Duration: 0
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Fade from Black not triggering

Post by rykaan »

Hi Tony,

Thanks for the great support as usual. It looks like adding in a buffer of black screen before the fade in animation was the way to go in the end. I'm trying to keep things simple by pausing the game during conversations/transitions etc so that monsters don't catch and talk to the player while something else is going on. So turning off 'pause during transition' would just give me a tonne of extra work. I did have to add a new black screen animation to the 'Enter Scene' node or the black screen would be at 0 alpha then jump to 1 and fade back out again. But it's working great now so no worries.

Really glad to have put that issue to bed, I had another nightmare issue to sort out yesterday to so getting those both out the way is a big load off my mind.

Thanks again!
Rob
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fade from Black not triggering

Post by Tony Li »

Glad to help!
Post Reply