I’m working on a trading card game. This is my cardData class (simplified):
public class cardData : MonoBehaviour {
public string cardName;
public int cardManaCost;
public int cardHp;
public int cardAttack;
}
I have a function that creates a card by cloning the card prefab that contains the above script.
Card createCard(int n){
clone the prefab;
pick the data for the n-th card in a List that contains the data for all the cards;
assign the right texture for the card;
return the card;
}
So as you can see at step 2 in the “createCard()” function, I want to have a list with the data for all the cards. So I created another class “cardData2” that is the same as “cardData” displayed above ^. I want to create objects of this class and put them in a List.
My question is: how do I create instances of this class? I can’t work with Monobehaviour because I don’t want to attach this script to any game object. Or do I?
I’m confused, and I’m looking for the best solution here but also looking to understand how Unity works with non-monobehaviour classes. I can’t seem to instantiate this script if it’s just in my resources folder. Please let me know what would be the best approach in your oppinion.
Thanks