
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
기능상의 문제는 없으나 오류코드가 뜨는게 신경쓰여 여쭤봅니다.
게임매니저 스크립트의 Matched 함수에서, if(firstCard.idx == secondCard.idx) 때문에 오류가 나는데요
첫번 째 카드를 클릭한 순간에 두번 째 카드에 할당되어있는 값이 없어서 오류코드가 발생하는 것 같습니다.
기능상 문제는 없으나 오류코드가 나오지 않게 만들어줄 방법으로 뭐가 있나요?


/public void Matched()
{
if(firstCard.idx == secondCard.idx)
{
firstCard.DestroyCard();
secondCard.DestroyCard();
cardCount -= 2;
if (cardCount == 0)
{
Time.timeScale = 0f;
endTxt.SetActive(true);
}
}
else
{
firstCard.CloseCard();
secondCard.CloseCard();
}
firstCard = null;
secondCard = null;
}
NullReferenceException: Object reference not set to an instance of an object
GameManager.Matched () (at Assets/Scripts/GameManager.cs:50)
Card.OpenCard () (at Assets/Scripts/Card.cs:44)
UnityEngine.Events.InvokableCall.Invoke () (at <fde3c13fb32a45329a891b3df03f7908>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <fde3c13fb32a45329a891b3df03f7908>:0)
UnityEngine.UI.Button.Press () (at ./Library/PackageCache/com.unity.ugui@24b10291b18f/Runtime/UGUI/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at ./Library/PackageCache/com.unity.ugui@24b10291b18f/Runtime/UGUI/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@24b10291b18f/Runtime/UGUI/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@24b10291b18f/Runtime/UGUI/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@24b10291b18f/Runtime/UGUI/EventSystem/EventSystem.cs:530)
