**So, I am making an UNO game.
I have a class called CARD that has :
using UnityEngine;
using System.Collections;
public enum KIND
{
RED,
BLUE,
GREEN,
YELLOW,
PICK,
DRAW4,
};
public class CARD : MonoBehaviour {
[HideInInspector]
public KIND COLOR;
[HideInInspector]
public string ID;
[HideInInspector]
public GameObject CARDObJECT;
public CARD(KIND clr, string id, GameObject cardobject)
{
COLOR = clr;
ID = id;
CARDObJECT = cardobject;
}
}
I created all UNO cards by making a list of CARD, one example is this:
CARD greenZero = new CARD(KIND.GREEN, "zero", GREEN_ZERO);
I thought i was doing well untill i hit a very very frustrating wall.
When i give the player his first 5 cards i did like this:
public void DealInitialToPlayers()
{
int initialCardsDeal = 5;
for (int i = 0; i < initialCardsDeal; i++)
{
PlayerCards.Add(CardsBank*);*
CardsBank.RemoveAt(i);
}
for (int y = 0; y < PlayerCards.Count; y++)
{
Instantiate(PlayerCards[y].CARDObJECT,new Vector3(-2.5f+y*1.20f,-4,0),Quaternion.identity);
// Instantiate(PlayerCards[y].CARDObJECT, new Vector3(0 + y * 1.20f, 0, 0), Quaternion.identity);
}
CardsOnBoard.Add(CardsBank[0]);
CardsBank.RemoveAt(0);
Instantiate(CardsOnBoard[0].CARDObJECT, new Vector3(0 , 0, 0), Quaternion.identity);
}
this will give the player 5 cards and put one on the middle. I also initiated the cards prefabs to the screen,
My problem is, how can I access the initiated prefab’s item variables (the string ID,the enum).
For example there is now one card in the middle, how can I know its KIND(color), its ID.
It feels like i initiated the GameObject with no information from the CARD class i worked really hard to make.**