[SOLVED] Unity opens scene as script (problem, error, bug)
Hello and good day
So recently I unistalled Unity pro 2018 and installed Unity Pro 2019.2.2f1. And now I have an irritating problem.
I use VSC (Visual Studio Code) to do my scripting. Whenever I try to open a scene from inside Unity, it opens it as a script inside VSC. I don't know what's causing this. I checked the scene files, they have the Unity icon and if I open them from there, they open inside the Editor. I've checked my default app settings and they're all ok, but the problem persists.
If I open the scene from inside Windows Explorer myself, it opens as a scene inside Unity Editor. But if I try to open it from inside Unity Editor, it opens it as a script.
I've searched many times and have found no topics relating to this issue.
Does anyone have any idea on how I can fix this? It's annoying as hell!
Answer by Chimz · Sep 11, 2019 at 08:42 PM
Alright, I found a solution. Go to Edit\Prefrences\External Tools. From there, change the first option called "External Script Editor" to "Open by file extension". This will fix the problem.
I also had this problem with Animator Controllers. Whenever I double clicked them, they would also be opened by Visual Studio.
Answer by Apompili · Aug 28, 2019 at 04:55 PM
Same here. Every time I try to open a scene visual studio opens, and unity doesn't open the scene. If you need this version of unity, a work around is going open > scene > and select the scene you want to open.
Answer by justDeek · Aug 28, 2019 at 07:28 PM
If you're on Windows (which I suspect), something that always helped me fix opening .unitypackage related errors is the regex file I added to the attachments. It usually helps when some program messed with the file association, but it might also help in your case. If it's not allowed to post regex files directly, create a .txt file with the following content and change it's file extension to '.reg', then run it / "install" it:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.unityPackage]
@="Unity package file"
"backup_val"="Unity package file"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file]
@="Unity package file"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\DefaultIcon]
@="\"C:\\Program Files\\Unity\\Editor\\Unity.exe\",0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\shell]
@="open"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\shell\edit]
@="Edit Unity package file"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\shell\edit\command]
@="\"C:\\Program Files\\Unity\\Editor\\Unity.exe\" -openfile \"%1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Unity package file\shell\open\command]
@="\"C:\\Program Files\\Unity\\Editor\\Unity.exe\" -openfile \"%1\""
I found it a few years ago somewhere in the Unity forum (there multiple versions floating around the internet), so I can't give direct credit. It should also work on Unity instances installed via the UnityHub.
Hmm, I just tried it, but it didn't work. $$anonymous$$ade a .txt file on desktop, changed it to .reg, added your code with Notepad ++ and installed it, restarted Unity and the problem still persists.
Your answer
Follow this Question
Related Questions
Working with multiple scenes? 0 Answers
How's my SceneManager? 0 Answers