using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Health : MonoBehaviour
{
Slider slider;
// Start is called before the first frame update
void Start()
{
slider.value = 1;
}
// Update is called once per frame
void Update()
{
Debug.Log(slider.value);
}
}
When I run the code this error is shown :
NullReferenceException: Object reference not set to an instance of an object
Health.Update () (at Assets/Test/Health.cs:20)
Slider and UI is underlined red.
I can’t seem to understand the problem here.
And UnityEngine.UIElements is shown in the dropdown list whereas UnityEngine.UI is not found.
Please Help.