"Can't add script behaviour VisualContainerAsset. The script needs to derive from MonoBehaviour" - from 2d rouglike tutorial

So I started new Unity tutorial and everything went smooth till it gave me error as above in the title when I was trying to attach my scripts to the empty game object. After trying for some time I decided to create a new project with the same Asset folder from the tutorial site and started to create new empty scripts just to see if they can be attached to the game object and it worked! But to make sure, I created a few more, with different names and suddenly the 4th script upon creation got the message “No MonoBehaviour scripts in the file, or their names don’t match the file name” and after trying to attach it to the game object it got the same error again. Moreover, every other script upon creation gets the same note and cannot be attached, but the first 3 scripts don’t have it and can be successfully added to the game object.


P.S.: Maybe you can tell me also why does the script called GameManager have different icon than the rest of the scripts?

The game manager is a common in all proyects, couse that they change the icon to be better to selecti it because usually is more important than common scripts.

Your problem may be an error when it compiles. You may have a combination when compile that muddle Unity. I have sometimes that problem. I just delete it close unity and create a new script. If you are using visual studio try changing solution. :slight_smile: