How to assign methods to OnSelectedUsable through script on Proximity Selector?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
GinMartini
Posts: 10
Joined: Sun Mar 03, 2019 2:07 pm

How to assign methods to OnSelectedUsable through script on Proximity Selector?

Post by GinMartini »

Hello,

How do I assign methods from another gameobject to the proximity selector's OnSelectedUsable method?

I got this so far:

proximitySelector.onSelectedUsable.AddListener(

But then I'm completely lost. Is this even the right path to go down, or am I totally missing the right way to do this?

Thank you!

EDIT: Okay, as usual—the SECOND I post a question to a forum—I figure out a solution. For those wondering, here's what worked for me:

proximitySelector.onSelectedUsable.AddListener(delegate { someScript.someMethod(); });

I'd be curious to see if there's a better way to do this, or if there is some issue with the solution I found! Thanks again!
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to assign methods to OnSelectedUsable through script on Proximity Selector?

Post by Tony Li »

Nope, AddListener() is the way to do it. If you want to access the Usable that got selected, you can do it similarly like this:

Code: Select all

proximitySelector.onSelectedUsable.AddListener((usable) => { SomeMethod(usable); });
GinMartini
Posts: 10
Joined: Sun Mar 03, 2019 2:07 pm

Re: How to assign methods to OnSelectedUsable through script on Proximity Selector?

Post by GinMartini »

Thank you! I appreciate the follow up!
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to assign methods to OnSelectedUsable through script on Proximity Selector?

Post by Tony Li »

Happy to help!
Post Reply