46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
public class CardSpawnTest : MonoBehaviour
|
|
{
|
|
[Header("Card Prefab")]
|
|
public GameObject cardPrefab;
|
|
|
|
[Header("Card Setting")]
|
|
public float cardScale = 2f;
|
|
|
|
public Vector3 frontRotation = new Vector3(-90f, 0f, 90f);
|
|
public Vector3 backRotation = new Vector3(90f, 0f, 90f);
|
|
|
|
[Header("Player Cards")]
|
|
public Transform playerCardPos1;
|
|
public Transform playerCardPos2;
|
|
|
|
[Header("Dealer Cards")]
|
|
public Transform dealerOpenCardPos;
|
|
public Transform dealerHiddenCardPos;
|
|
|
|
void Start()
|
|
{
|
|
SpawnCard(playerCardPos1, false);
|
|
SpawnCard(playerCardPos2, false);
|
|
|
|
SpawnCard(dealerOpenCardPos, false);
|
|
SpawnCard(dealerHiddenCardPos, true);
|
|
}
|
|
|
|
void SpawnCard(Transform pos, bool faceDown)
|
|
{
|
|
GameObject card = Instantiate(cardPrefab, pos.position, Quaternion.identity);
|
|
|
|
card.transform.localScale = cardPrefab.transform.localScale * cardScale;
|
|
|
|
if (faceDown)
|
|
{
|
|
card.transform.rotation = Quaternion.Euler(backRotation);
|
|
}
|
|
else
|
|
{
|
|
card.transform.rotation = Quaternion.Euler(frontRotation);
|
|
}
|
|
}
|
|
} |