#Help with OnClick()

1 messages · Page 1 of 1 (latest)

pseudo zinc
#

I guess a started message is required

solemn cosmos
#

huh

charred nimbus
#

Your cards can have a script that holds its index. Then you can check if that index is the same as the randomly generated one

#

Or have a list of those cards in the parent class, and use List.IndexOf to get the index of a certain card in that list

pseudo zinc
charred nimbus
#

You could just add a PickedCorrect and PickedWrong function and then assign those to each card, depending on if its the correct one or not

pseudo zinc
#

Would I still be able to assign the correct card as random with that method though?

charred nimbus
#

I don't see why not

pseudo zinc
#

I'm having some issues with the implementation of this, as I'm not really sure of how to reference the card that I have clicked. I'm gonna sleep on it and think more about it in the morning. Thank you for your help Osmal

charred nimbus
#

Have the card script on the same object as the button. Add a method like Clicked to the card script. Then in the button's inspector, assign that Clicked method to the button's onClicked

#

You can do this also with AddListener from a script, but in this case could be easier to just assign it in the inspector