

카드 8종이 2장씩 배치되지 않고 일부 카드가 3장 배치되는 문제가 발생했습니다.
항상 그런 것은 아니고 일정 시도 시마다 간헐적으로 발생하는 문제입니다.
화면 하단의 오류메시지에는
NullReferenceException: Object reference not set to an instance of an object 라고 뜹니다.
오류메시지는 카드 짝이 맞던 안맞던 매 시도마다 계속해서 뜨고 있습니다
(매 판 카드를 처음 뒤집기 시작할 때부터 발생)
board 코드에서 문제가 있을 것이라 예상중이므로 하단에 제가 작성한 board 스크립트를 첨부합니다.
작성한 코드 및 에러 메세지
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Board : MonoBehaviour
{
public GameObject Card;
// Start is called before the first frame update
void Start()
{
int[] arr = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
arr = arr.OrderBy(x => Random.Range(0f, 7f)).ToArray();
for (int i = 0; i < 16; i++)
{
float x = (i % 4) * 1.4f - 2.1f;
float y = (i / 4) * 1.4f - 3.0f;
Instantiate(Card, new Vector2(x, y), Quaternion.identity);
Card.GetComponent<Card>().Setting(arr[i]);
}
}
}
