Fading to Black Between Dialogue Entries

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
willoneill
Posts: 9
Joined: Sun Oct 25, 2015 4:06 pm

Fading to Black Between Dialogue Entries

Post by willoneill »

Hey Tony,

I think I've got a pretty good handle on the Sequence system, and have been using it to cut to different angles when going back and forth between Actor and Conversant, but one thing that I'd really like to do is rather than have the camera immediately smash cut from one camera to another, I'd like to fade out to black, then change cameras while everything is still black, and then fade back in on the new camera.

I've been trying to do this with a combination of Sequence commands, but I can't get it - a big problem is that the Dialogue Text starts showing up right away, when what I want is for the camera to finish fading in. But is there even any way to do that? Can you delay the appearance of the Dialogue Text until the first part of a Sequence (the fading in) is finished?

I think you know what I want to do here. Have it fade in on the Actor, then their Dialogue Text appears. Then the user clicks, and it vanishes and the camera fades to black. Then, while black, the camera switches to the Conversant, then it fades in. Then the Conversant's Dialogue Text appears, and the same thing happens, back and forth.

If it's just a really complicated sequence that I have to set up, no worries - just wondering if there is something obvious and easy that I'm missing.

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

Re: Fading to Black Between Dialogue Entries

Post by Tony Li »

Hi Will,

Subtitles and sequences work independently. This is a good thing for most cases. For your situation, the key is to pause the typewriter effect. You can use the SendMessage sequencer command to tell it to Pause and Unpause. Say you want to pause the typewriter effect on the NPC Subtitle Line (assuming that's the name of the GameObject in your dialogue UI):

Code: Select all

SendMessage(Pause,,NPC Subtitle Line)
The whole thing might look like this:

Code: Select all

SendMessage(Pause,,NPC Subtitle Line);
Fade(in,0.5);
SendMessage(Unpause,,NPC Subtitle Line)@0.5;
Fade(out,0.5)@5
The sequence above pauses the typewriter immediately and fades in over 0.5 seconds. At the 0.5-second mark, it unpauses. At the 5-second mark, it fades out.

You can use the "->Message" and "@Message" syntax to automate some of the timing:

Code: Select all

SendMessage(Pause,,NPC SubtitleLine);
Fade(in,0.5)->Message(FadedIn);
SendMessage(Unpause,,NPC Subtitle Line)@Message(FadedIn);
Fade(out,0.5)@5
Here's a more complex example that fades out of the player closeup and then fades into the NPC closeup. Put it on the NPC's line.

Code: Select all

SendMessage(Pause,,NPC SubtitleLine);
Fade(out,0.5);
Camera(Closeup)@0.5;
Fade(in,0.5)@0.5;
SendMessage(Unpause,,NPC Subtitle Line)@1;
Fade(out,0.5)@5
I used numbers instead of @Message above because, in hindsight, I think it makes the timing easier to read in this case.

How frequently do you want to do this? If it's every single line, that's a heck of a lot of type. If that's the case, I could probably put together a single sequencer command that calls all those other sequencer commands under the hood.
willoneill
Posts: 9
Joined: Sun Oct 25, 2015 4:06 pm

Re: Fading to Black Between Dialogue Entries

Post by willoneill »

Hey Tony,

Thanks for getting back to me with such detailed guidelines! For reference, here's the code I'm testing based on yours:

Code: Select all

SendMessage(Pause,,NPC Subtitle Line);
Fade(out,0.5);
Camera(Closeup, speaker)@0.5;
Fade(in,0.5)@0.5;
SendMessage(Unpause,,NPC Subtitle Line)@1;
Just got rid of that last fade out, it wasn't needed (since it happens again at the beginning of the next sequence!)

The only problem I'm still having is that the 'pause' doesn't seem to actually stop the subtitles from beginning to get typed out - it just makes the window not *appear* until the unpausing occurs. Because of that, you see a line that is already half-written by the time it unpauses (if it is long enough) or already completely finished - in which case you don't see the typewriting effect at all.

I know explaining this is a little weird, so I made a GIF of it: http://imgur.com/8Ebt1dD

Is there any way around this? Any way to make the typing truly not begin until the object is unpaused?

I totally understand that your system is built to make subtitles and sequences independent, so I'm thinking maybe there is no way to deal with this. I can't expect you to totally undo a fundamental way the system works just to deal with this, so please just let me know if this is the way it is. I can find another way to work around it or re-conceive of what I want to do creatively to accomodate it. :)

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

Re: Fading to Black Between Dialogue Entries

Post by Tony Li »

Hi - That looks like a bug in the typewriter effect's Pause/Unpause functionality. I'll look into it and get back to you.

BTW, by "system" I only mean the way I chose to implement the default Unity UI dialogue UI system. The Dialogue System for Unity itself is completely input/output independent, so you can do anything with it. Anyway, your case is completely reasonable and is entirely possible with the default Unity UI system. Assuming it's a bug in Pause/Unpause, I'll post a small patch later today to address it.
willoneill
Posts: 9
Joined: Sun Oct 25, 2015 4:06 pm

Re: Fading to Black Between Dialogue Entries

Post by willoneill »

Tony,

That's great to hear! I hope it is a bug that you're able to squash. Please let me know how it goes, and if there's anything I can do to help you test or diagnose it further.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fading to Black Between Dialogue Entries

Post by Tony Li »

Hi Will,

You can download an update to the Unity UI support scripts on the Dialogue System Extras page. The previous code was correctly doing exactly what I intended when I originally wrote it, which was to make up for time lost during the pause by jumping ahead. The bug was between the keyboard and the chair. :-) If you import the updated package, the pause feature will now more appropriately resume typing where it left off, without trying to jump ahead.
willoneill
Posts: 9
Joined: Sun Oct 25, 2015 4:06 pm

Re: Fading to Black Between Dialogue Entries

Post by willoneill »

Hey Tony,

Thanks! Unfortunately, it doesn't seem like anything has changed for me. It's still exactly the same.

To try and isolate the problem, I created an entirely new Unity project, did a fresh import of Dialogue System (using the prefab with the default UI) and then did an import of the new package. I can confirm that I've got the new version of your UnityUITypewriterEffect script - the filename says 2:02 a.m. from this morning.

I set up a simple back and forth dialogue in the new project and got the same results - the subtitles start building even though it should be paused, and when it unpauses the stuff is already built.

However, I did note that immediately following the new package import, I got some errors in the console. I've put together an imgur gallery for you here:

http://imgur.com/a/Yb1Vd

Hope this helps! I figured it was just something to do with how I set up my project or its UI, but having gone totally fresh and with the prefab default, I'm not sure what might be different in our respective environments.

Let me know if anything jumps out at you! Thanks!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fading to Black Between Dialogue Entries

Post by Tony Li »

Sorry again, I had packed up the wrong version of the typewriter effect in that Unity UI Support package. Please download the correct package from the Extras page or directly here: DialogueSystem_UnityUI_2015-11-22.unitypackage. I probably shouldn't be trusted to commit changes to the repository at 2am on a Saturday night. Rest assured that full releases of the Dialogue System go through a thorough battery of automated tests to cut me and my human errors out of the loop. ;)

Here's a test scene to confirm that it works: TestConversationFade_2015-11-22.unitypackage
willoneill
Posts: 9
Joined: Sun Oct 25, 2015 4:06 pm

Re: Fading to Black Between Dialogue Entries

Post by willoneill »

Hi Tony,

No problem at all! These things happen, and it was a small bump in the road compared to the tremendous assistance you've offered me. :)

Everything is now working just as I'd hoped! Thanks again.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Fading to Black Between Dialogue Entries

Post by Tony Li »

Great, glad it's working! And thank you very much for the kind review! :-)
Post Reply