I’ve got a list of GameObjects that I’m using as a player’s deck. They’re all a bunch of prefabs, and the game will take the objects off the top of the list to put in the player’s hand, like this:
public void DrawCard(){
GameObject card = (GameObject)Instantiate (cardsInDeck[0]);
cardsInDeck.RemoveAt (0);
hand.cardsInHand.Add (card);
}
However, I need to be able to serialize this list before the game in a “collection” screen, so folks can build decks to play etc. I just found out that GameObjects aren’t serializable, and so my plans for saving decks aren’t going to work the way I thought.
I’ve thought of a couple ways I solve this, maybe by converting the GameObjects to a bunch of ints and then converting them back afterwards, but I’m not really sure the best way to go about this. Maybe a switch statement? I also read a little bit about plugins etc. that let you serialize GameObjects, but I think I’d prefer to avoid doing anything like that since it seems like there might be an easy way to do this. What’s the best workaround for serializing a bunch of GameObjects?
Thanks!