- Home /
Scripts won't derive from MonoBehaviour
For some time now i've been having an issue with creating C# scripts, where when i make a new script from the unity editor (Create > C# script) and open the script for editing it will not derive from MonoBehaviour.
When i reïmport the script or restart Unity/VS2017 it sometimes fixes the issue, but most of the time i need to delete the script and make a new one until it does correctly add MonoBevahiour.
Manually deleting : MonoBehaviour
and re-adding it does change anything either. And there are no errors in the console.
edit: "MonoBehaviour" also doens't highlight in green as it normally would, but instead stays plain white colour
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Foo : MonoBehaviour // <- does not load correctly
{
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update(){
}
}
Any suggestions as to what more i can try would be very welcome since having to delete/create scripts until it works is quite annoying.
Thanks in advance! ~Remy
Is this in Visual Studio? $$anonymous$$onodevelop?
Either way, I would try closing the IDE, deleting the solution & project files, and then re-opening the project from Unity (Assets menu -> Open C# project). This will make it re-create the solution hopefully with the right DLLs in the right places.
Your answer
![](https://koobas.hobune.stream/wayback/20220612142243im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Making a static class derive from MonoBehaviour in C# 3 Answers
Class derivation problem 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers