No MonoBehaviour script in the file whenever I create a script
Hi every one I just downloaded Unity and am getting to know how to work with it in the context of a 2d game, every time I try to create a script it gives me this damned error, it can't be anything wrong in the file because even the default code Unity inputs still doesn't work... It's been like two days I've been trying to get this fixed but I don't know what the issue is...
Probably a stupid question. Have you looked in one of the scripts, just to confirm that the template was used for a unity $$anonymous$$onoBehaviour?
It should look something like this...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DummyScript : $$anonymous$$onoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
Answer by ThomasOr · Dec 15, 2019 at 10:40 AM
If you've added a c# file to unity and you can't see it in the editor then it's either:
Have a look at Larry-Dietz comment
not inheriting from mono (doesn't follow the syntax: 'class className : MonoBehaviour')
there is a compiler error in your code somewhere (if you play ctrl+p and no dice)
you've messed around with your workflow and probably just want to start a new project and copy the assets folder over (nothing else this is important)
or, finally, you are performing some action to block unity from adding files to the csproj file(s) but that is extremely unlikely.
if it's 2 then add the : etc. if 3 then you need to fix your errors if 4 then do as I said if 5 then you have caused it so probably only you can fix it because I'm not even sure how you could do this in the first place but if a fresh project doesn't work then this is the problem and again, this is most definitely not the answer
Your answer
Follow this Question
Related Questions
No MonoBehaviour script in the file whenever I create a script 0 Answers
how create EndLess game Like zombie Tsunami 1 Answer
problim with dontdestroyonload and counts death as 2 0 Answers
NullReferenceException: Object reference not set to an instance of an object in Singleton class. 1 Answer
Is there any way to trigger a popUp UI when a player steps in a specific set of tiles? 0 Answers