I really can’t understand why i cant connect variable from other script with UI text. Console on load says me error
NullReferenceException: Object reference not set to an instance of an object
UISHIT.Update () (at Assets/SCRIPTS/UISHIT.cs:22)
My code in UI script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.Playables;
using System.Runtime.InteropServices.WindowsRuntime;
public class UISHIT : MonoBehaviour
{
//stamina text
public TextMeshProUGUI input;
//trying to get access to variable in other script
public readonly SC_FPSController Stamina;
void Awake()
{
//trying to get access to variable in other script again
GetComponent<SC_FPSController>();
}
void Update()
{
input.SetText(Stamina.ToString());
}
}
Variable in other script
public static float Stamina = 100.0f;