Witam, tworzę taką prostą grę i chcę by gdy gracz przegra pojawiał się komunikat że przegrał i ile uzyskał punktów użyłam do tego UI.Text
public GameObject textField;
public Text text ;
public void gameover(){
if (points > record)
record = points;
if (record < points)
text.text = "Przegrałeś ): Uzyskałeś " + points + " punktów " + (record - points) + " punktow do pobicia rekordu";
else
text.text = "Pobiles swoj rekord ! Gratulacje ! Uzyskales " + points + " punktow";
textField.SetActive(true);
}
Mój problem polega na tym że gdy gracz przegrywa i zostaje wywołana funkcja gameover() pojawia mi się taki błąd
NullReferenceException: Object reference not set to an instance of an object
playerController.gameover () (at Assets/scripts/playerController.cs:24)
Wskazuję na linie 24 czyli :
text.text = "Pobiles swoj rekord ! Gratulacje ! Uzyskales " + points + " punktow";
Text się niestety nie zmienia.
Jak to naprawić ?
Z góry dziękuje za pomoc