Hi,
I'm working on some touch control for my game and I wanted to make a button on screen that would basically trigger the "OnUse()" fonction to interact with objects (opening doors, treasure, etc).
I tried simply calling ProximitySelector.UseCurrentSelection() when clicking on the button, but for some reason I get an error and found out that the 'currentUsable' variable is null. What's weird is that if I make a debug.log in ProximitySelector's Update method to write the value of currentUsable in the console, I see that it's not null.
The OnUse() works when I use the keyboard key, but won't work when I try calling it with a button on screen. Can you help me with this? Thanks!
Calling "OnUse()" from script?
Re: Calling "OnUse()" from script?
Hi,
Can you configure your UI button to call the Dialogue System Trigger's OnUse() method directly?
If you only want to show the UI button when the player is near the Dialogue System Trigger, you can add a trigger collider and Trigger Event to the Dialogue System Trigger GameObject. Configure the Trigger Event's OnTriggerEnter() UnityEvent to show the UI button and OnTriggerExit() UnityEvent to hide it.
If you want to use ProximitySelector, then as a debugging step make sure the selector UI is visible when you press the UI button. I don't know why that error would be reported. If you can't identify the issue, please feel free to send a reproduction project to tony (at) pixelcrushers.com
Can you configure your UI button to call the Dialogue System Trigger's OnUse() method directly?
If you only want to show the UI button when the player is near the Dialogue System Trigger, you can add a trigger collider and Trigger Event to the Dialogue System Trigger GameObject. Configure the Trigger Event's OnTriggerEnter() UnityEvent to show the UI button and OnTriggerExit() UnityEvent to hide it.
If you want to use ProximitySelector, then as a debugging step make sure the selector UI is visible when you press the UI button. I don't know why that error would be reported. If you can't identify the issue, please feel free to send a reproduction project to tony (at) pixelcrushers.com