Colour change to show correct answer

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jmnb
Posts: 22
Joined: Thu May 26, 2022 4:38 am

Colour change to show correct answer

Post by jmnb »

I would like to set up the dialogue system so that if a wrong answer is clicked the colours of the text change so that wrong answers appear in red and the correct answer appears in green. To do this i will have to prevent a mouse click from advancing the dialogue, and also communicate the colour change to the UI. Any tips on setting this up would be gratefully received! Thanks. :P
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Colour change to show correct answer

Post by Tony Li »

Hi,

You could add a script to your response buttons, and point the Button component's OnClick() event to a method in that script instead of StandardUIResponseButton.OnClick().

In that method, check if the answer is the right answer or wrong answer.

If it's the right answer, call the button's StandardUIResponseButton.OnClick() method.

If it's the wrong answer, loop through the buttons and set the colors. If your menu uses a button template to instantiate buttons into the menu as needed, loop through DialogueManager.standardDialogueUI.conversationUIElements.defaultMenuPanel.instantiatedButtons. If your menu uses a predesigned list of buttons in the Buttons list, loop through DialogueManager.standardDialogueUI.conversationUIElements.defaultMenuPanel.buttons.
jmnb
Posts: 22
Joined: Thu May 26, 2022 4:38 am

Re: Colour change to show correct answer

Post by jmnb »

Thanks! :D
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Colour change to show correct answer

Post by Tony Li »

Happy to help!
Post Reply