How to make prefab clones selectable?
Edit: In players hand, for every card in it, I create a Box Collider as a component of that specific card clone game object. But I can't reach the cards seperately with OnMouseDown().
For a card game, I have a card prefab and I create clones of it after starting the game. In the players hand, I want these card clones to be selectable. How can I do this?
The function I use for the cards to be seen after adding them to the hand is:
void AddCard(Vector3 position, int i, int cardCount) {
if (fetchedCards.ContainsKey(i)) return;
GameObject cardCopy = (GameObject)Instantiate (cardPrefab);
cardCopy.transform.position = position;
CardModel cardModel = cardCopy.GetComponent<CardModel>();
cardModel.cardIndex = i;
}
Your answer
Follow this Question
Related Questions
Onmouseclick on Cube a sphere should be created inside the cube and On second click it shouldn't 1 Answer
Selecting one instantiate prefab 1 Answer
2D - OnMouseDown not working despite having a collider 0 Answers
Creating obj/prefab > Card. Better way? 0 Answers
Why this happens?? Spawned object problem 2D, Tetris Game. 0 Answers