Hello, so im new at scripting, i have been scripting player vitals, like food, drink, health. I have created three sliders, then i started scripting in Visual Studio.
I did everything that i wanted , i just changed UnityEngine to UnityEngine.UI
And i had this problem: The MonoBehaviour didnt worked, it said something like it couldnt be found, or the name dont exist. So i changed it back to UnityEngine, then it said: That the slider doesnt work again, couldnt find slider or something, can someone help me?
Screenshot:
You need to include both UnityEngine.UI and UnityEngine Scripts in your headers like:
using UnityEngine.UI;
using UnityEngine;
Since i’m pretty new myself, the only explanation I think i can give is that you’re trying to access both UI and standard scripts of UnityEngine, so you should include both scripts in your header. Monobehaviour is a class you can only access from the UnityEngine script and isn’t in UnityEngine.UI script, so if you don’t include UnityEngine, MonoBehaviour doesn’t exist and you’ll get an error,You need to include both UnityEngine.UI and UnityEngine Scripts