Combine two Dialogue Entries into a single sentence
- bohemian pulp
- Posts: 21
- Joined: Wed Apr 21, 2021 7:01 am
Combine two Dialogue Entries into a single sentence
Hello everybody!
I wondered if there is a way to combine two Dialogue Entries into a single sentence so that I could have different endings depending on conditions.
For example:
1. Starting entry: "I want to go"
2. entry 1: "camping."
3. entry 2: "fishing."
So if a character said sometime before that he likes fishing, it would automatically write: "I want to go fishing." as a single sentence. I am aware I could do it with variables, but combining would fit so much more. There was a similar thing in Inkle, and, weirdly, there is no option like this for UDS. Or I'm missing it? I tried adding Continue(), but then it doesn't display the subtitle. That's another question, by the way. Is there a way to sequence a continue button press and also show the text?
I'm sorry if this is a duplicate topic. I searched and couldn't find anything on this.
I wondered if there is a way to combine two Dialogue Entries into a single sentence so that I could have different endings depending on conditions.
For example:
1. Starting entry: "I want to go"
2. entry 1: "camping."
3. entry 2: "fishing."
So if a character said sometime before that he likes fishing, it would automatically write: "I want to go fishing." as a single sentence. I am aware I could do it with variables, but combining would fit so much more. There was a similar thing in Inkle, and, weirdly, there is no option like this for UDS. Or I'm missing it? I tried adding Continue(), but then it doesn't display the subtitle. That's another question, by the way. Is there a way to sequence a continue button press and also show the text?
I'm sorry if this is a duplicate topic. I searched and couldn't find anything on this.
Creator of "Let Bions be bygones"
https://linktr.ee/bohemianpulp
https://linktr.ee/bohemianpulp
Re: Combine two Dialogue Entries into a single sentence
Hi,
There isn't a way to do exactly that without a little scripting. But you could use a group node to group those entries:
To sequence the continue button, use the Continue() sequencer command. For example, to simulate a continue button click after 3 seconds, set the entry's Sequence field to:
There isn't a way to do exactly that without a little scripting. But you could use a group node to group those entries:
To sequence the continue button, use the Continue() sequencer command. For example, to simulate a continue button click after 3 seconds, set the entry's Sequence field to:
Code: Select all
Continue()@3
- bohemian pulp
- Posts: 21
- Joined: Wed Apr 21, 2021 7:01 am
Re: Combine two Dialogue Entries into a single sentence
Thanks for the answer, mate!
I wasn't using the groups, I'll add them to my workflow, unfortunately, that doesn't help.
Continue()@2 is also something I didn't use, it almost does the job, but it's still in two lines, and I'd like it to be a single uninterrupted sentence.
Maybe I want to build it from for example:
1. I would like / I want / I was going
2. to go / to spend time
3. camping / fishing / relaxing
It would be a lot of variables to handle that, and only a couple of conditions if it would print the text as a single sentence without breaking every entry.
I wasn't using the groups, I'll add them to my workflow, unfortunately, that doesn't help.
Continue()@2 is also something I didn't use, it almost does the job, but it's still in two lines, and I'd like it to be a single uninterrupted sentence.
Maybe I want to build it from for example:
1. I would like / I want / I was going
2. to go / to spend time
3. camping / fishing / relaxing
It would be a lot of variables to handle that, and only a couple of conditions if it would print the text as a single sentence without breaking every entry.
Creator of "Let Bions be bygones"
https://linktr.ee/bohemianpulp
https://linktr.ee/bohemianpulp
Re: Combine two Dialogue Entries into a single sentence
Hi,
Note that the group node ( {group}<I want to go...> ) doesn't actually contribute any text to the conversation. It's just a grouping mechanism. The two nodes that it links to ("I want to go camping" and "I want to go fishing") contain the complete text for the sentence.
Since this is outside the regular purview of the way Dialogue System conversation trees work, if you don't want to use group nodes then you could use a little supplemental scripting. Let's say you write your conversation like this:
You could add a script to the Dialogue Manager that has an OnConversationLine method. This method can check if the current line ends with the string "[...]". If so, it can accumulate that text to be shown later instead of showing it now. Here's a rough example (typed directly in here; may have typos):
HandleAccumulatedText.cs
(Edit: Added "using" statements.)
Note that the group node ( {group}<I want to go...> ) doesn't actually contribute any text to the conversation. It's just a grouping mechanism. The two nodes that it links to ("I want to go camping" and "I want to go fishing") contain the complete text for the sentence.
Since this is outside the regular purview of the way Dialogue System conversation trees work, if you don't want to use group nodes then you could use a little supplemental scripting. Let's say you write your conversation like this:
You could add a script to the Dialogue Manager that has an OnConversationLine method. This method can check if the current line ends with the string "[...]". If so, it can accumulate that text to be shown later instead of showing it now. Here's a rough example (typed directly in here; may have typos):
HandleAccumulatedText.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HandleAccumulatedText : MonoBehaviour
{
private string accumulatedText;
void OnConversationLine(Subtitle subtitle)
{
if (subtitle.formattedText.text.EndsWith("[...]"))
{
// Accumulate this text instead of showing it:
accumulatedText += subtitle.formattedText.text.Replace("[...]", string.Empty);
subtitle.formattedText.text = string.Empty;
subtitle.sequence = "Continue()";
}
else
{
// This line doesn't have [...], so prepend any accumulated text:
if (!string.IsNullOrEmpty(accumulatedText))
{
subtitle.formattedText.text = accumulatedText + subtitle.formattedText.text;
accumulatedText = string.Empty;
}
}
}
}
- bohemian pulp
- Posts: 21
- Joined: Wed Apr 21, 2021 7:01 am
Re: Combine two Dialogue Entries into a single sentence
Awesome!
I'll tinker with it, and let you know what I ended up with
Thanks again for the support!
I'll tinker with it, and let you know what I ended up with
Thanks again for the support!
Creator of "Let Bions be bygones"
https://linktr.ee/bohemianpulp
https://linktr.ee/bohemianpulp
- bohemian pulp
- Posts: 21
- Joined: Wed Apr 21, 2021 7:01 am
Re: Combine two Dialogue Entries into a single sentence
It says this:
I'm not a coder, so I have no idea what to do to fix it
Code: Select all
Assets\Dialogue System Examples\HandleAccumulatedText.cs(9,29): error CS0246: The type or namespace name 'Subtitle' could not be found (are you missing a using directive or an assembly reference?)
Creator of "Let Bions be bygones"
https://linktr.ee/bohemianpulp
https://linktr.ee/bohemianpulp
Re: Combine two Dialogue Entries into a single sentence
Hi,
I omitted some things for brevity. I just added the "using" statements at the top of the code in my previous reply. That should resolve the errors.
I omitted some things for brevity. I just added the "using" statements at the top of the code in my previous reply. That should resolve the errors.
- bohemian pulp
- Posts: 21
- Joined: Wed Apr 21, 2021 7:01 am
Re: Combine two Dialogue Entries into a single sentence
Works like a charm!
You should definitely add this to extras if not integrate it into the plugin itself. It's a great thing to have.
Keep up the great work!
You should definitely add this to extras if not integrate it into the plugin itself. It's a great thing to have.
Keep up the great work!
Creator of "Let Bions be bygones"
https://linktr.ee/bohemianpulp
https://linktr.ee/bohemianpulp
Re: Combine two Dialogue Entries into a single sentence
Thanks! I'll write this up as a "How To" post here.