Page 1 of 2

How to use Custom Sequencer?

Posted: Fri Mar 18, 2016 4:56 pm
by Nonlin
NOTE: Trying to port over an older NGUI version of a project to the latest Unity and SD.

Right now my dialogue logic doesn't continue when clicking a button like it should.
I know the method that should get called is and managed to get it called.
The next thing that should happen is a sequence that plays audio/animates.

I've noticed that on the Dialogue Manager a Conversation View and Sequencer Script components get attached to the Dialogue Manager (which I'm not sure what for but know it must be required). In the old project upon clicking on a choice it also generate a custom sequencer which calls the code to play audio/animate.

My question is, what generates this custom play audio sequencer? What tells it to make and attach these scripts? Is this unique to this project and not a function of System Dialogue?

I know that in my port even though the Dialogue Manger was copied over it does not generate the custom sequencer script and it does not get attached to the DM. Figuring this out should hopefully solve most of my problems.

Re: How to use Custom Sequencer?

Posted: Fri Mar 18, 2016 8:50 pm
by Tony Li
Hi,

My post in your other thread briefly describes what ConversationView does. Here's a quick summary that's more relevant to this thread:
  • ConversationModel: Maintains the data state of an active conversation (current dialogue entry, available responses, etc.).
  • ConversationView: Handles everything visible to the player (subtitles & response menus, sequences, etc.).
    • Dialogue UI: Shows subtitles and response menus as directed by ConversationView.
    • Sequencer: Plays sequences received from ConversationView. When showing subtitles, the ConversationView won't advance to the next stage in the conversation until the Sequencer is done playing the sequence, or if the continue button is clicked.
      • Individual sequencer commands: Spawned by the Sequencer.
  • ConversationController: Coordinates between ConversationModel (which is purely the internal data stuff) and ConversationView (the player-visible stuff).
So all of that is built into the Dialogue System; it's not unique to your project.

If the Dialogue Manager's Continue Button dropdown is set to a mode that requires the player to click the continue button, the subtitle will not advance when its sequence is done. It will wait for the player to click the continue button. Make sure your continue button is configured to call the dialogue UI's "OnContinue" method. If you're using the UnityUIContinueFastForward script, configure your continue button to call its "OnFastForward" method instead. The Generic Unity UI Dialogue UI may provide a helpful example of how to set up continue buttons.

You can also fake a continue button click by using this sequencer command:

Code: Select all

SendMessage(OnContinue,,Dialogue Manager,broadcast)
To add it to your Sequence field without having to type it, click the "+" button to the right of the Sequence field and select Continue > Simulate continue button click.

I'm not sure if this next bit will be helpful for your project, but you can also turn the continue button mode on and off using the SetContinueMode() sequencer command.

Please feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look. I'm sure you want to get back to actually making your game instead of battling dialogue UI stuff. ;-)

Re: How to use Custom Sequencer?

Posted: Sat Mar 19, 2016 11:29 am
by Nonlin
Thanks for the responses Tony. Really appreciate them.

I realize most of it is built in but there is certainly a custom CommandSequencer script getting added to the dialogue manger some how along with the two default one that get added on it.

I have yet to find out how this is happening but it happens when one of the response buttons is clicked.
Can you shed light on how that may be done?

Re: How to use Custom Sequencer?

Posted: Sat Mar 19, 2016 2:58 pm
by Tony Li
Hi,

Does that response have a custom sequencer command in its Sequence field?

What's the name of the custom sequencer command? For example, in the inspector it should appear as something like "Sequencer Command Foo" while the command is running.

If you want to see what custom sequencer commands are available in your project, search in the Project view for "SequencerCommand". This will match "SequencerCommandLoadLevel", "SequencerCommandAnimation", etc. Some of these are built-in commands, too.

If you set the Dialogue Manager's Debug Level to Info, then right after this kind of line:

Code: Select all

Dialogue System: <character> says: '<something>'
it will log lines like:

Code: Select all

Dialogue System: Sequencer.Play( <command> )
where <command> is a sequencer command.

This might give you a better idea where the command is coming from.

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 10:07 am
by Nonlin
The response buttons contain NGUIResponseButton scripts.
I do not see them having a sequence field.

Yes it is called SequencerCommandPlayAudio.

I'll try looking into the info logs.

EDIT: The main difference seems to be that OnClick from NGUIResponseButton gets called (triggering the sequences?), but since I never got OnClick working I simply added a listener to what I thought should have been the next call.

Not sure why the OnClick for TextMeshProResposneButton doesn't get called.
Also in the old project nothing is defined for the NGUI buttons OnClick (via inspector).

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 10:37 am
by Tony Li
Hi,
Nonlin wrote:Yes it is called SequencerCommandPlayAudio.
This must be a custom sequencer command of your own. Please search your project for SequencerCommandPlayAudio.cs.
Nonlin wrote:Not sure why the OnClick for TextMeshProResponseButton doesn't get called.
NGUI buttons always send an "OnClick" message to all scripts on the button, regardless of whether any handlers are assigned via inspector.

Unity UI buttons (and TextMesh Pro by extension) don't do this. They only invoke the handlers that you've assigned via inspector or via code using AddListener. Make sure you've assigned a handler, such as the TextMeshProResponseButton's OnClick method.

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 10:52 am
by Nonlin
Yes I'm aware that it is custom, I'm just not sure what is invoking it to attache as a component to Dialogue Manager.

Ok so NGUI could be calling it but that doesn't mean its calling anything.
I have added a Listener to the response logic that was getting called in the older project but that alone has not been cutting it.
I still don't understand how the responses are getting updated and sequences triggered.
All that was being done (as far as I can tell) is a callback of a response so I made sure to just add a listener to that call back.
It gets called but no actions proceed as they did.
All the project seems to contain is Conversations Triggers but no sequence triggers.

EDIT: It would also seems that Dialogue Manager by some means enables and disables the response buttons. Also not sure how this is being accomplished.
EDIT: Not sure if it helps to mention but the info logs show Dialogue System: Lua(return Actor... for the outdated working project. Clicking on the debug shows its origin to be from the OnClick method.

I do not get these results in the new project.

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 11:29 am
by Tony Li
Nonlin wrote:Yes I'm aware that it is custom, I'm just not sure what is invoking it to attach as a component to Dialogue Manager.
Sorry, I understand what you mean now. One of the dialogue entry nodes in your dialogue database must have a Sequence field that calls PlayAudio(), or your Dialogue Manager's Camera Settings > Default Sequence calls PlayAudio(). When the Dialogue System encounters a sequencer command it doesn't recognize, it uses reflection to find a matching custom sequencer command class. Then it adds an instance to the Dialogue Manager and runs it.
Nonlin wrote:Ok so NGUI could be calling it but that doesn't mean its calling anything.
I have added a Listener to the response logic that was getting called in the older project but that alone has not been cutting it.
I still don't understand how the responses are getting updated and sequences triggered.
All that was being done (as far as I can tell) is a callback of a response so I made sure to just add a listener to that call back.
It gets called but no actions proceed as they did.
All the project seems to contain is Conversations Triggers but no sequence triggers.
I may need a little clarification. I'll try to provide a little more background info first. You're probably well aware of most if not all of this, but I'm filling in gaps just in case.

A conversation is a tree of dialogue entry nodes. NPC entries are drawn as gray nodes. PC entries are drawn as blue nodes.

When an active conversation gets to a gray NPC entry, it (1) shows the entry's Dialogue Text and (2) plays its Sequence*.

When the conversation gets to a set of blue PC entries, it sets up the response menu buttons with the entries' Menu Text. (If Menu Text is blank, it uses Dialogue Text.) Each button has a UnityUIResponseButton (or TextMeshProResponseButton) script that has a reference to the dialogue entry.

When the player clicks a response menu button, the button should invoke the UnityUIResponseButton's OnClick method. This method sends the dialogue entry to the UnityUIDialogueUI (or TextMeshProDialogueUI) as a response. At this point, the dialogue UI plays the entry's Sequence**. If the Dialogue Manager is configured to Show PC Subtitles During Line, it will also show the entry's Dialogue Text. When the Sequence is done, it follows the dialogue entry's link to the next stage in the conversation.


* For NPC entries, if the Sequence field is blank, the Dialogue System will play the Dialogue Manager's Default Sequence.

** For PC entries, if the Sequence field is blank, the Dialogue System will play the Dialogue Manager's Default Player Sequence. If the Default Player Sequence is blank, it will play the Default Sequence.


In your NGUI version, is it possible that your response buttons have a script with an OnClick method? If so, then in your Unity UI/TextMesh Pro version you may need to assign this to the response button's On Click () event handler.

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 11:40 am
by Nonlin
Ok got it working although not sure why it works this way.

OnClick from NGUI was sending a message OnClick as well as its callback. I was calling the call back but never sending the OnClick message.
I chagned the listener from just calling the callback to call OnClick which sends the message and calls the callback.
Now it seems to be working but again not sure why but this seems to be how.

EDIT: Now it freezes on a prompt but might be unrelated to this.
Seems like one of those continue button functions System Dialogue provides?

EDIT: No its there just was hidden. :D

Re: How to use Custom Sequencer?

Posted: Mon Mar 21, 2016 11:49 am
by Tony Li
Is it working now?