How to add responses via C# code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wolf-mvp
Posts: 2
Joined: Sat Mar 04, 2023 9:19 am

How to add responses via C# code

Post by wolf-mvp »

Hello,
I want to add response options via C# code. I already have working Conversation, but just need to add player answers via C# code.

For example: scene have a trader and I want to buy someting.
I need to add array of options via C# code.

For example:
"I want to buy an apple for 10 gold"
"I want to buy sword for 50 gold"
"I want to buy a hat for 30 gold"

and then move to next dialogue entry with saved choice (this can be done with DialogueLua.SetVariable as I know).

I try to find ability to add response options via C# code, but no luck.
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add responses via C# code

Post by Tony Li »

Hi,

The simplest way is probably to create the conversation at runtime. See: How To: Create Dialogue Database At Runtime
wolf-mvp
Posts: 2
Joined: Sat Mar 04, 2023 9:19 am

Re: How to add responses via C# code

Post by wolf-mvp »

Hi, Thanks for response.

I think is is too complicated for me to changle full logic and create the conversation at runtime.

I make some workaround to copy/paste buttons at runtime with required actions.

I think - issue is solved.
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add responses via C# code

Post by Tony Li »

Alright. Another approach would be to use variables. If you run into any issues with your solution, let me know and I can write up how you could use variables in response nodes to handle this.
Post Reply