Search Unity

Find out what object was selected

Discussion in 'Scripting' started by kdarius43, Jul 31, 2015.

  1. kdarius43

    kdarius43

    Joined:
    Mar 16, 2015
    Posts:
    170
    Hello All,

    I have 6 cards showing at once. I am trying to find out the best way to know which one is picked to be used later. we can call the cards 1-6 so if someone selects card 2 all the other cards hide and card 2 is stored so later in the game it knows you selected card 2. I thought about creating script for each card but that seems like over kill. Is there a script i can give each card that is the same but checks to see what game object was selected?
     
  2. kdarius43

    kdarius43

    Joined:
    Mar 16, 2015
    Posts:
    170
    or should i do it when a card is select a new level opens knowing that card was selected?
     
  3. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Give each card a script that reports that it was clicked to a single "manager" object. Then you can reference that manager object to find out what card was selected later.