"Miscellaneous Files" Making Scripts Not Work

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?

well, it appears to me that it's a problem with your script editor not able to find the reference of the actual script's file location. It might be possible to open your script manually through the script editor, but that would quickly become difficult. I don't know a real fix to a problem like this, however you should be able to work if you manually open it until someone has a good answer. From a bystander's point, we might need more information, however I don't know how you could give info like 'how is unity referencing your scripting editor' easily.

15 Answers

15

Go to Edit > Preferences > External Tools and then change “External Script Editor” to Visual Studio.

I spent hours trying to figure this out, and it finally works. Thanks!

This worked for me, also.


Try rebuilding the solution, or install Visual Studio Unity Tools

@Snipe76 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.

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”.

This worked for me.

Worked for me too

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.

Thanks so much your comment helped me out a bunch

In 2022, this problem still persists. But your solution fixed it. Thanks! I'm using Unity 2021.3.1f1 and Visual studio 2019 16.11.17 Deleting the added existing file doesn't revert the project back to miscellaneous files. So you can also go ahead and delete the extra file to keep your existing folder structure organized.

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.

@Snipe76

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.

Hi, I solved it using this tutorial.

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!

Finally! I was scrolling through this page trying (almost) all the solutions, nothing worked. Your message solved it for me! Here, only a few files were marked as Miscellaneous after I moved them to a subfolder, and sometimes it happens right after creating or duplicating a new file, where it was fixed by changing the name, but I don't want to change the name (when I changed the name, it fixes it, but then the problem returned if I reverted to the previous name).

  • Solved this on my end by excluding and including the specific file that was causing the issue.

This should fix it: Preferences → External Tools → Regenerate project files.