Question by
stipendawarded · Jul 30, 2018 at 07:45 PM ·
scripting probleminspectorerror messagepublic variable
Public Variables Not Displaying In The Inspector
I am having a serious issue. In my current project, the scripts say "No MonoBehavior scripts in the file, or their names do not match the file name". I am bringing this up since my public variables are not showing up in the inspector. Are these issues related? Please respond ASAP.
Comment
Answer by Jon_T · Apr 15, 2020 at 06:37 PM
Hi, The error is telling you that the class either does not derive from MonoBehaviour or the name of the class is not the same as the file name. So your public variables aon't show unless the two above conditions are met. ie:
// this class is derived from (is a sub class of) MonoBehaviour
// Unity needs this for a class to be added to a GameObject
public class MyScriptClass : MonoBehaviour
{
public string myVariable = "My Variable";
}
// the above code should also be contained in a file called MyScriptClass.cs
Your answer
Follow this Question
Related Questions
Animator does not show up 0 Answers
Cant add script becuase of error 2 Answers
Custom inspector for items in array. 1 Answer
Public variables not showing up 0 Answers