Answer the question
In order to leave comments, you need to log in
Object reference not set to an instance of an object. What could be the problem?
I am trying to repeat the code from this video
CardInfoScr.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class CardInfoScript : MonoBehaviour
{
public Card SelfCard;
public Image Logo;
public TextMeshProUGUI Name;
public void ShowCardInfo(Card card)
{
SelfCard = card;
// Ошибка
Name.text = card.Name;
Logo.sprite = card.Logo;
Logo.preserveAspect = true;
}
private void Start(){
ShowCardInfo(CardManager.AllCards[transform.GetSiblingIndex()]);
}
}
NullReferenceException: Object reference not set to an instance of an object
CardInfoScript.ShowCardInfo (Card card) (at Assets/Scripts/CardInfoScript.cs:22)
CardInfoScript.Start () (at Assets/Scripts/CardInfoScript.cs:33)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question