- Home /
Creating a script doesn't work from the start.
So, sometimes when I create a new script, it creates the script and opens up VS and all that, but when i start coding, nothing works.
From the very second I make it, MonoBehaviour is just regular white, instead of switching to blue(which it does in all of my working scripts), and all the code that comes afterwards is also regular white, except for "void"s, they turn green(as they should).
It sometimes worked to delete the script, and make it again, but now it won't do anything. I can still write in the other scripts of the project.
I've been programming for about a month now, and just started using unity last week, so it might be a stupid mistake, but nonetheless, I can't find anything about this.
Try to restart VS it will fix it for me, it mostly happens when i create many scripts at once mainly on 5.6 version. It seems like when a new class is created VS will not reload/load the related Assemblies. Probably a bug on VS's side.
Answer by unit_nick · Sep 13, 2017 at 06:06 AM
My guess is you are not including the required using statements at the start of the script.
For example MonoBehaviour requires using UnityEngine;
If that is the case and you are using VS and it is correctly configured it should hopefully underline it. In which case you can just hover over it and press ALT + Enter and it will provide a link to insert the missing code automatically.
Answer by BellyMeister · Sep 13, 2017 at 10:33 AM
@unit_nick all the "using" was there, they were already written when I made the C# script. I still don't know what the problem was, but it was fixed by restarting the computer, and re-creating it again.
Kind of hoping there'll be a permanent fix to this, so I don't have to create the same script 3 times, but it works as of right now.
Answer by OusedGames · Sep 13, 2017 at 01:29 PM
Hello buddy, that's a bug with just created scripts.
Just close you script editor (mono/visual studio) and open it again
Hope it works