How to see what element is the current one

I have a number of cards in the List ‘hand’. Each turn another card gets added which works perfectly. Now I’m trying to, when you play a card, that card accesses the List to shift all other cards’ transforms to fill the gap. But only the numbers in the List that are above that card’s number.

So my question is actually, is there a built-in variable that gives the number/rank of the current element?

I assume you’re using a list?

JS:


var handcards : List.;
var card : Card;

function Update (){
    Debug.Log(getIndex(card));
}

function getIndex(element : Card) : int
{
    for (var i : int = 0; i < handcards.Count; i++)
    {
        if (handcards *== card)*
 *return i;*
 *}*
 *// in case the card is not in your hand return -1*
 *return -1;*
*}*
*```*

I believe what you want is List.IndexOf

http://msdn.microsoft.com/en-us/library/e4w08k17.aspx

http://www.dotnetperls.com/list-indexof