Using non-UI gameobjects as response buttons
-
- Posts: 8
- Joined: Tue Jan 23, 2024 6:26 am
Using non-UI gameobjects as response buttons
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!
Re: Using non-UI gameobjects as response buttons
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:
Then replace your dialogue UI's StandardUIMenuPanel with your subclass: How To: Replace Script with Subclass and Keep Field Assignments
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);
-
- Posts: 8
- Joined: Tue Jan 23, 2024 6:26 am
Re: Using non-UI gameobjects as response buttons
Glad to help! If you have any questions about setting it up, let me know.