#ISelectHandler

1 messages · Page 1 of 1 (latest)

scenic kiln
#

If I understand correctly, I'd wager this is because unity is specifically hardcoded to try to call OnSelect. That's the point of its API system. It allows the game dev to know what unity is going to call and when so they can utilize it accordingly.

Luckily, they already have a system that lets you accomplish what you're trying to do.

You can first define the alternate functions for each selection type. Then, inside your OnSelect function, you can check the data of the argument passed in an if/else if block to determine which type of select was made, and then call the corresponding alternate function.

paper jackal
#

So, if I understood correctly (just to provide more context as well)

I'd like to have this happen when I select the attack command in my UI:
An arrow (image) shows up next to the attack command.
The arrow (also an image) that is next to the shield command disappears.

And the reverse happens when I select the shield command.

So now I have to set this up with an if-else statement within that OnSelect function?

scenic kiln
#

Hmmm I think that would actually require multiple scripts using the select handler interface, one for each selectable ui object

#

Lemme double check real quick

paper jackal
#

Wow, alright. I thought Unity could handle this a bit better by default 😄

#

Sure. I wouldn't mind just doing multiple scripts either way

#

Thanks for helping by the way

scenic kiln
#

Ah ok, so you're looking to do "radio buttons"

#

but if you want to do it the way you are now, the objects would need their own scripts and a way to update some managing object to change the UI stuff

paper jackal
#

Okay, got it

#

Thanks o/