Scripting problem, sliders, monobehaviour
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:
Answer by ratorv2 · Nov 03, 2018 at 11:30 PM
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
Your answer
Follow this Question
Related Questions
How to assign slider to float: Spin, on a gameobject 1 Answer
Prefab UI Slider misses the fill and background items... 0 Answers
Swapping characters breaks controls 0 Answers
I need help fixing my movement/jetpack script, it involves a slider. 0 Answers
Making a slider, slider does nothing even when attached to the script? 1 Answer