Hi there.
I'm trying to add a list of custom responses that are generated in a script to the dialogue manager. So far I've managed to find the specific response menu I need to access with the OnConversationResponseMenu event, and I can read the responses that exist, but I can't figure out a way to modify those responses. I understand that I can take the Response[] array and find the text of each response added in the conversation tree, but what I need is irregardless of how many options are already created in the tree, I want to replace every response with one generated in the script.
Is there a way I might be able to do this?
Thanks in advance.
Add responses programatically
Re: Add responses programatically
Hi,
You might want to create an entire conversation at runtime. If so, please see: How To: Create Dialogue Database At Runtime
Otherwise, you could make a subclass of StandardUIMenuPanel that overrides ShowResponses(), and completely ignore the Response[] array that's passed to it, instead adding your own responses.
You might want to create an entire conversation at runtime. If so, please see: How To: Create Dialogue Database At Runtime
Otherwise, you could make a subclass of StandardUIMenuPanel that overrides ShowResponses(), and completely ignore the Response[] array that's passed to it, instead adding your own responses.
Re: Add responses programatically
Thank you Tony, this worked pretty well for me. I ended up creating a new database at runtime and deleting it after the conversation, following the tutorial post you linked. By the way, having the power to use Unity Events on a conversation node within the script is really nice. I found that by using a delegate, I'm not limited to the parameter options I'd usually find in the editor.Tony Li wrote: ↑Thu Feb 20, 2025 8:20 pm Hi,
You might want to create an entire conversation at runtime. If so, please see: How To: Create Dialogue Database At Runtime
Otherwise, you could make a subclass of StandardUIMenuPanel that overrides ShowResponses(), and completely ignore the Response[] array that's passed to it, instead adding your own responses.
With that said, I have a small hitch which would be nice to fix, I'm hoping you might be able to point me in a direction.
When I'm creating this new database and new conversation, I'm still using characters that already exist in my main database, and I'd like to use their actors, mostly so that I get to have their names show up in the new conversation. How would I go about getting their names displayed?
Thank you for the help!
Re: Add responses programatically
Hi,
Just use their actor IDs, which you can get from DialogueManager.masterDatabase. For example, to assign the "Player" actor to an entry:
Since your runtime database and the original design-time database will be merged into the same DialogueManager.masterDatabase (at least until you remove and destroy your runtime database), your runtime-created conversation can reference anything that's in the design-time database.
Just use their actor IDs, which you can get from DialogueManager.masterDatabase. For example, to assign the "Player" actor to an entry:
Code: Select all
var playerActor = DialogueManager.masterDatabase.GetActor("Player");
someDialogueEntry.ActorID = playerActor.id;
Re: Add responses programatically
That worked great, thank you very much, Tony!Tony Li wrote: ↑Mon Feb 24, 2025 7:42 am Hi,
Just use their actor IDs, which you can get from DialogueManager.masterDatabase. For example, to assign the "Player" actor to an entry:
Since your runtime database and the original design-time database will be merged into the same DialogueManager.masterDatabase (at least until you remove and destroy your runtime database), your runtime-created conversation can reference anything that's in the design-time database.Code: Select all
var playerActor = DialogueManager.masterDatabase.GetActor("Player"); someDialogueEntry.ActorID = playerActor.id;
Re: Add responses programatically
Happy to help!