Using non-UI gameobjects as response buttons

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jonathancarroll
Posts: 5
Joined: Tue Jan 23, 2024 6:26 am

Using non-UI gameobjects as response buttons

Post by jonathancarroll »

I'm creating a VR game incorporating Dialogue System, and want to use physical buttons the player pushes to trigger different responses (example image attached). Is there some documentation on how to accomplish this? I currently have the pushable button triggering StandardUIResponseButton.OnClick (or StandardUISubtitlePanel.OnContinue if there are no options) - any pointers on how I would trigger different buttons for different responses? thanks!
Screenshot 2024-01-23 at 7.20.37 AM.png
Screenshot 2024-01-23 at 7.20.37 AM.png (137.26 KiB) Viewed 490 times
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using non-UI gameobjects as response buttons

Post by Tony Li »

Hi,

You can make a subclass of StandardUIMenuPanel or replace the dialogue UI entirely with your own implementation of the C# IDialogueUI interface. The folder Plugins/Pixel Crushers/Dialogue System/Templates/Scripts contains a starter script for writing your own implementation of IDialogueUI.

If you make a subclass of StandardUIMenuPanel, override the ShowResponses() method to set up your GameObjects instead. ShowResponses() is given a target, which is the main dialogue UI. Record this target variable. When the player interacts with one of the GameObjects, use this code to send the response back to the target:

Code: Select all

target.SendMessage("OnClick", response, SendMessageOptions.RequireReceiver);
Then replace your dialogue UI's StandardUIMenuPanel with your subclass: How To: Replace Script with Subclass and Keep Field Assignments
jonathancarroll
Posts: 5
Joined: Tue Jan 23, 2024 6:26 am

Re: Using non-UI gameobjects as response buttons

Post by jonathancarroll »

Thank you!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using non-UI gameobjects as response buttons

Post by Tony Li »

Glad to help! If you have any questions about setting it up, let me know.
Post Reply