Got a weird editor issue with C# scripts: They won't open correctly
Hey,
I'm not sure if this is a common issue of just something with my computer, but I am using Unity 5.3.4 and whenever I create a new C# script, the little icon next to the name is blank white and has no C# icon on it. In addition to this, these new scripts don't open in Visual Studio Community and open in Notepad only. At the end of the scripts' file directory name, instead of NewBehaviourScript.cs for example, they say NewBehaviourScript.cs - Copy. Does anyone know how to fix this annoying bug? Or have I done something by accident that caused this?
Just so you know, this may be a result of me changing the script templates because the editor is asking for C:\ProgramFiles\Unity\Editor\Data\Resources\ScriptTemplates\81 - C# Script NewBehaviourScript.cs - Copy.txt ins$$anonymous$$d of a non-copy...
Answer by btmedia14 · Jun 29, 2016 at 02:27 AM
You've kind of answered your own question.
There is a numbering and naming convention used for the template files in directory C:\ProgramFiles\Unity\Editor\Data\Resources\ScriptTemplates\
In your case, template 81 used for C# scripts has the "-Copy" suffix and so each new script file created will have that suffix attached. As such, it will not be recognised as a C# file, which needs to end as filetype .cs.
1) Within that template directory, ensure the template is named as:
81-C# Script-NewBehaviourScript.cs.txt
This will correct for any scripts going forward.
2) For your existing project scripts, locate the directory under Assets containing the generated script files and rename any containing the suffix "-Copy" by removing that suffix and simply having ".cs" as the filetype.
Thanks for helping me out. I'm new to Unity and I was looking for a way to change my script templates.
I managed to fix it a few hours later by changing the end of the file to NewBehavioursScript.cs.txt because it had renamed itself to a .cs file when I edited it. A simple restart of the engine realigned the file with the engine. Thanks for helping though.
And to cap things off, I'm the king of answering my own questions without noticing :) Thanks for the help and now I can get back to coding my FPS in peace.