For some reason every time I make a script it shows up at “Miscellaneous Files” (see picture below) and it makes the script unable to work, and every single script does this and there is no way to fix it, any suggestions?
Go to Edit > Preferences > External Tools and then change “External Script Editor” to Visual Studio.
What I do is just open the containing folder (Actually finding the folder outside of Visual Studio), then drop it into the proper project folder within the “Solution Explorer”.
That unfortunately didn’t work for me, and the bug is still there. It appears to be an unresolved bug in Visual Studio (up to at least the 2017 release).
I’ve tried a bunch of the solutions people have posted, and the only one that seemed to fix it was to go to Project/Add Existing Item in Visual Studio and then select any .cs file in my project. That seemed to fix the “miscellaneous files” bug, not only for that one file but for all of them.
I hope this helps someone else who’s having this issue.
This solved the problem for my project on Visual Studio 2022:
- Solution
- Assembly-CSharp (right-click)
- Load entire dependency tree
I could resolved with: (I have Visual Studio community 2019 version)
- click Edit >Preference
- External Tools
- Check Player projects
Re-open your script.
This issue persists for me. rebuilding the Solution does not remove the miscellaneous file. Nor does it on any new script I try to do this on.
Also tried installing the unity tools, but nothing changes.
I had this problem when my files were in a sub folder of an another sub folder.
- e.g:
scripts/sub1/sub2/example.cs
I fixed it by refactoring my folders structure and moving my cs files from sub2 to sub1.
scripts/sub1/example.cs
I know it’s a little late, but I had the same issue and none of the solutions worked for me, so this is what I did:
Open Solution Explorer in VS Assembly-CSharp > Assets > YourScriptFolder rightclick on your script(s) and chose Include In Project.
You might need to increase the Windows filepath length, to allow it greater than 256 characters for filepaths.
In my case, the several files were very deep in folders and caused the long filepaths issue. Search online how to increase it (via Registry & regedit). You’ll have to restart PC afterwards.
I had set external tool to correctly visual studio, and it still not fix…
I recreate project files and it still not fix…
so I decided to reimport all assets and everything fixed!