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.
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?
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/unity_tutor...