Page 1 of 1
Using non-UI gameobjects as response buttons
Posted: Tue Jan 23, 2024 6:49 am
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 (137.26 KiB) Viewed 530 times
Re: Using non-UI gameobjects as response buttons
Posted: Tue Jan 23, 2024 9:37 am
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
Re: Using non-UI gameobjects as response buttons
Posted: Wed Jan 24, 2024 11:00 am
by jonathancarroll
Thank you!
Re: Using non-UI gameobjects as response buttons
Posted: Wed Jan 24, 2024 11:55 am
by Tony Li
Glad to help! If you have any questions about setting it up, let me know.