That being said it should be close and I believe it demonstrates my point. My explination will assume that this compiles.
- A Mesh for your card. Make sure that all UV's are unitized. In other words. The UVs for the each face of the card should be a square stretching from (0,0) in the bottom left corner to (1,1) in the top
- A texture atlas with all of your card faces.
- each texture needs to be spaced consistently
- Make a new game object with the
CardFactory
MonoBehaviour from this Gist. - Fill out the public properties in the inspector.
- This script assumes that the size of the texture atlas along each side is a perfect multiple of the size of your cards. In other words, if the Rows = 3 & Colums 4, a single card texture will have a height exactly 1/3 of the atlas height and 1/4 of the atlas width.
- Create a
Material
asset with your texture. Any will do. - Make another gameobject with a
MeshRenderer
,MeshFilter
and add theMaterial
from step 3 to this gameObject. - Run the scene. Once the gameobject awakes, it should fill up the
Deck
array on theCardFactory
with new meshes. Simply drag one of the Meshes in theDeck
array into theMeshFilter
mesh slot to check it out.