using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CardManager : MonoBehaviour
{
public static CardManager instance;
[SerializeField]
private List<Image> cardObjects;
[SerializeField] private GameObject cardHolder, cardPrefab, dummyCardPrefab;
private int k;
private void Awake()
{
if (instance == null)
{
instance = this;
}
}
private void Start()
{
for (int i = 0; i < 20; i++)
{
k = i;
SpawnCard();
}
}
void SpawnCard()
{
GameObject card = Instantiate(cardPrefab);
card.name = "Card" + k;
card.transform.SetParent(cardHolder.transform);
card.GetComponent<CardView>(). SetImg(cardObjects[k]);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CardView : MonoBehaviour
{
private Image img;
private void Awake()
{
img = GetComponent<Image>();
}
public void SetImg(Image cardObjects)
{
img = cardObjects;
}
}