As far as I understand, in previous versions of Unity it was necessary to write like this, to access UI elements:
using UnityEngine.UI;
But now, in the latest versions, like this:
using UnityEngine.UIElements;
The problem is that when I'm creating two Slider and Text objects, there is no place to attach the Slider object to the script in the Inspector. There is also no such Text class.
[SerializeField] private Text levelText;
[SerializeField] private Slider healthSlider;