Registering a C# Function that calls OnContinue
Registering a C# Function that calls OnContinue
Some of the nodes in my conversations need to immediately traverse to the next node depending on certain conditions. I'm using Unity 4.6's UI system, so it looks like the OnContinue function of the UnityUIDialogueUI class is what I need. I registered a C# function to the Dialogue System's Lua environment that gets the current instance of the dialogueUI and calls the OnContinue function to see if it works as expected:
DialogueManager.Instance.displaySettings.dialogueUI.GetComponent<UnityUIDialogueUI>().OnContinue();
I created a simple conversation that contains the start node, an empty node that calls the above function, and a 3rd node that contains some dialogue text. What I would expect to happen is that the empty node would immediately be skipped and the conversation would traverse to the 3rd node, so on the surface it looks like the conversation only contains the start node and the 3rd, dialogue node.
However, after calling this function, Unity freezes for about a minute and then states that a StackOverflowException was thrown.
Is there any way that I can immediately travel to the next node from a node in the Dialogue Editor? This method seemed like an elegant solution, but it appears that the internal details of the system prevent it from working.
Thank you,
Andrew
DialogueManager.Instance.displaySettings.dialogueUI.GetComponent<UnityUIDialogueUI>().OnContinue();
I created a simple conversation that contains the start node, an empty node that calls the above function, and a 3rd node that contains some dialogue text. What I would expect to happen is that the empty node would immediately be skipped and the conversation would traverse to the 3rd node, so on the surface it looks like the conversation only contains the start node and the 3rd, dialogue node.
However, after calling this function, Unity freezes for about a minute and then states that a StackOverflowException was thrown.
Is there any way that I can immediately travel to the next node from a node in the Dialogue Editor? This method seemed like an elegant solution, but it appears that the internal details of the system prevent it from working.
Thank you,
Andrew
Registering a C# Function that calls OnContinue
Hi Andrew,
That's good thinking, but it's even easier to accomplish what you want.
If you have not set the Dialogue Manager's Continue Button mode to a setting that waits for a continue button click, then simply set the dialogue entry's Sequence field to:
None()
This is a "null operation" sequencer command. The Dialogue System normally waits until the sequence is done. This command finishes immediately, so the Dialogue System immediately progresses to the next step in the conversation.
If you have set the Dialogue Manager's Continue Button mode to wait for a continue button click, then set the Sequence field to:
SendMessage(OnContinue,,MyDialogueUI)
where "MyDialogueUI" is the name of your dialogue UI GameObject. This simulates a continue button click.
As an alternative, you can tick the dialogue entry's Is Group checkbox. This marks the entry as a decision point or hub. When the Dialogue System progresses through the conversation, it skips through this entry and evaluates its children instead. This provides an easy way to link to a single entry that branches off into different subtrees based on conditions. (The Dialogue System will respect the entry's Conditions and Script fields.)
That's good thinking, but it's even easier to accomplish what you want.
If you have not set the Dialogue Manager's Continue Button mode to a setting that waits for a continue button click, then simply set the dialogue entry's Sequence field to:
None()
This is a "null operation" sequencer command. The Dialogue System normally waits until the sequence is done. This command finishes immediately, so the Dialogue System immediately progresses to the next step in the conversation.
If you have set the Dialogue Manager's Continue Button mode to wait for a continue button click, then set the Sequence field to:
SendMessage(OnContinue,,MyDialogueUI)
where "MyDialogueUI" is the name of your dialogue UI GameObject. This simulates a continue button click.
As an alternative, you can tick the dialogue entry's Is Group checkbox. This marks the entry as a decision point or hub. When the Dialogue System progresses through the conversation, it skips through this entry and evaluates its children instead. This provides an easy way to link to a single entry that branches off into different subtrees based on conditions. (The Dialogue System will respect the entry's Conditions and Script fields.)
Registering a C# Function that calls OnContinue
Sweet! This isn't exactly what I needed, as I realized that I needed to wait for a certain amount of time before sending the OnContinue message, but you did point me in the right direction by using the Sequencer field instead.
I did something similar to my original plan and created my own Sequencer Command that triggered an OnContinue call after waiting a certain amount of time, and now everything works as desired!
Thanks again, Tony! I really appreciate this great help you give to all of us!
I did something similar to my original plan and created my own Sequencer Command that triggered an OnContinue call after waiting a certain amount of time, and now everything works as desired!
Thanks again, Tony! I really appreciate this great help you give to all of us!
Registering a C# Function that calls OnContinue
Hi Andrew,
Sounds like you're all set. If you want to simplify it in the future, you might want to look into the "@time" format for sequencer commands. You can do things like:
SendMessage(OnContinue,,MyDialogueUI)@2.5
to simulate the continue button after 2.5 seconds, or
SendMessage(OnContinue,,MyDialogueUI)@{{end}}
to wait a duration based on the length of the dialogue text.
This is digressing a bit, but you can also wait for messages from other parts of your game. This command:
SendMessage(OnContinue,,MyDialogueUI)@Message(AlarmWentOff)
waits until your code calls:
Sequencer.Message("AlarmWentOff");
Sounds like you're all set. If you want to simplify it in the future, you might want to look into the "@time" format for sequencer commands. You can do things like:
SendMessage(OnContinue,,MyDialogueUI)@2.5
to simulate the continue button after 2.5 seconds, or
SendMessage(OnContinue,,MyDialogueUI)@{{end}}
to wait a duration based on the length of the dialogue text.
This is digressing a bit, but you can also wait for messages from other parts of your game. This command:
SendMessage(OnContinue,,MyDialogueUI)@Message(AlarmWentOff)
waits until your code calls:
Sequencer.Message("AlarmWentOff");
Registering a C# Function that calls OnContinue
Jeez, guess I still have a lot to learn; that's way simpler!
Thanks again, mate.
Thanks again, mate.
Registering a C# Function that calls OnContinue
Actually, something a little strange happened when I tried putting
SendMessage(OnContinue,,DialogueUI)@1.5;
into the Sequence field of my node, I got the attached error as a result. Sorry to ask again so soon, but do you have any insight in this?
SendMessage(OnContinue,,DialogueUI)@1.5;
into the Sequence field of my node, I got the attached error as a result. Sorry to ask again so soon, but do you have any insight in this?
Registering a C# Function that calls OnContinue
Happy to help! Don't hesitate to ask if you're wondering how to do something. It's likely that many developers before you have been in the same situation and worked out efficient solutions that were then incorporated into the Dialogue System.
Registering a C# Function that calls OnContinue
Oops, our posts crossed. You can ignore that message. It's actually harmless. The next version avoids the situation that causes that message to appear. If it starts to drive you crazy, you can download a patch from the Pixel Crushers customer download site. I'll email you your access info.
Registering a C# Function that calls OnContinue
Haha, no worries. Just wanted to be sure I wasn't doing anything inappropriate.
Thanks again man, the support I've received has been fantastic.
Thanks again man, the support I've received has been fantastic.
Registering a C# Function that calls OnContinue
Oh, one more thing.
I didn't buy the Dialogue System on this email, so you might not be able to send me the access info based on my email on this fourm. The account that did buy it uses the email somthing1223@yahoo.com. Sorry about that.
I didn't buy the Dialogue System on this email, so you might not be able to send me the access info based on my email on this fourm. The account that did buy it uses the email somthing1223@yahoo.com. Sorry about that.