Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

12
How to know what UI element has been clicked
Post Body

So I'm making card game, and when I click card that is in my hand I want to assign it to some variable so I can do something with it (in my case, I want to summon it). I tried using raycast but it didn't work, I guess raycast doesn't work with UI elements. then I tried adding Button child gameObject to Card (parent gameobject) and by clicking on that Button I wanted to assign child's parent using:

GameObject parent = transform.parent.gameObject;

But it didn't work either, because GameObject "Card" is child of GameObject "Hand" which is child of GameObject "Player 1". So when I click on Button it doesn't assign "Card" (since it is parent object of Button), instead it assings master parent "Player 1".

So to simplify question, how to detect what UI element has been clicked so I can assign it to variable and do something with it?

Author
Account Strength
80%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
93
Link Karma
14
Comment Karma
25
Profile updated: 1 day ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago