onUse Touch Button

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

onUse Touch Button

Post by Albyd »

Hi guys, I'm here to ask for some help.
I would like to link the onUse function to a UI Touch Button.
It will be used as an "Action" button to interact with npcs and objects.
Can you help me?

Many thanks
Albyd
User avatar
Tony Li
Posts: 21020
Joined: Thu Jul 18, 2013 1:27 pm

Re: onUse Touch Button

Post by Tony Li »

Hi,

If you're using a Proximity Selector component, you can tick Enable Touch and specify the Touch Area. For example, if I set the Origin and Alignment to Bottom Left, and set the Width and Height to Normalized 0.5 (that is, 0.5 x the screen size):

selectorTouchArea1.png
selectorTouchArea1.png (45.22 KiB) Viewed 202 times

Then the touch area will be here:

selectorTouchArea2.png
selectorTouchArea2.png (170.76 KiB) Viewed 202 times

If you don't want to use the Touch Area or Proximity Selector, there are other solutions. If you're using a Selector or Proximity Selector, you can manually call the Selector or Proximity Selector's UseCurrentSelection() method.

If you're not using a Selector or Proximity Selector, you can manually call the target's OnUse() method, or send "OnUse" to all of its components like this:

Code: Select all

target.SendMessage("OnUse");
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

Re: onUse Touch Button

Post by Albyd »

Thank you very much bud.
I was stuck with this problem and your comment really helped me!
User avatar
Tony Li
Posts: 21020
Joined: Thu Jul 18, 2013 1:27 pm

Re: onUse Touch Button

Post by Tony Li »

Glad to help!
Post Reply