The editor sometimes outputs the following error when an asset gets reimported:
Please improve this error by including the script name that is causing it. Some pointers how to fix this error would be helpful too.
The editor sometimes outputs the following error when an asset gets reimported:
Please improve this error by including the script name that is causing it. Some pointers how to fix this error would be helpful too.
This happening for me when I have runtime and an editor script named the following:
Runtime script: MyNamespace.MyScript
Editor script MyNamespace.Editor.MyScriptInspector
If I change the editor script name to something more than just appending the word âInspectorâ on to the end it works fine.
Is this similar to the issue you are seeing?
+1 moving around scripts started causing this for me. Not cool.
The error just started to occur out of the blue once again. Every time I selected a mesh, it would spit out this error. Restarted the editor, problem went away.
Same in 2019.3.0f3. Using asmdef in the script folder that is causing it, not sure if that has anything to do with it.
But fine again after restartâŚ
This is a new error that we added due to a bug that was fixed. If the error is emitted, it means that are still other cases where there are bugs.
Internally in Unity we maintain caches of which scripts are editor scripts and which are runtime scripts. There was a bug in the editor where the root cause was that the same script was both in the runtime and editor cache. This bug occurred when moving scripts between editor and runtime assemblies, similar to the reports in this thread. Restarting the editor fixes it, because it forces the caches to be rebuilt.
We fixed the bug and at the same time added this error to detect if this issue could occur under other circumstances, instead of just silently ignoring it and it potentially causing other issues in the editor. And here we are
We will improve the error so it includes the full type name of the script that is causing the issue.
However, this error should never be emitted in the first place and it would be to great help for us if someone who has a consistent repro for it could report a bug and post the case number in this thread. We have no existing bug reports on this issue. Thank you.
As Lukasz mentioned, a bug report for this would be appreciated!
Just putting this here as it just happened and annoyed me but I donât have the time to create a proper repo project and doubly check what part of the action caused this to happen⌠This might help narrow it down somewhat.
I created a new monobehaviour inside a game side asmdef then created an instance of the behaviour in scene then created an editor for it in another asmdef that was set to not compile, then changed the editor asmdef to compile via changing a platform setting. Change the Editor script and deselect then re-select the gameobject instance in scene view and it happened to me.
Unity 19.3.0f6
Happened to me as well just now.
I prepared a package in the Assets folder, including a MonoBehaviour and a corresponding Custom Editor named
TextMeshProLocalization and TextMeshProLocalization_Inspector.
When I moved my Package to the Packages folder the error started happening.
I just experienced it as well when I downgraded postprocessing in an attempt to get it to work and rebuit a project. Using Unity 2018.4.22f1. I got postprocessing to work on a build a couple days ago, but after fiddling with some settings havenât been able to get it work since.
Here you go:
(Case 1293581) MonoScript is registered as both Editor and Runtime script
https://issuetracker.unity3d.com/issues/monoscript-is-registered-as-both-editor-and-runtime-script
I just got this error as well, and it appears every time I add my script as a component to an object.
Iâm trying to make a package, consisting of just a few scripts. One is a runtime script, and the other is an editor script, along with a script file containing some utility methods.
Hereâs the Editor folder and asmdef.
https://i.imgur.com/yiPuLYI.png
Hereâs the Runtime folder and asmdef.
https://i.imgur.com/cIxjHnS.png
In the script files, I have also put my classes in a namespace, similar to how Peter77 was doing it in the video.
Hi guys,
It seems that itâs because youâre trying to use an .asmdef into an Editor folder. I suggest you to rename your folder. It worked for us.
I keep running into this issue but donât understand how to avoid it. Can anyone tell whatâs going on? I wonât be seeing the fix from 2021.2 anytime soon because my company only updates to LTS releases.
Also, how long can it take to fix this sort of bug? Reported at the end of 2019, could have been a candidate for 2019 LTS, and now 2020 LTS has long passed, it gets fixed almost two years later. You can imagine how it feels to have these annoying editor bugs and deal with them for multiple game releases because Unity has too much on their plate, is too busy implementing DOTS or ArchViz while the usability of the editor slowly degrades. Sorry for the rant, but itâs been one of those Unity years where the editor is falling apart, but I have to give credit that the player has almost no issues ever.
I am in the process of backporting this fix to 2019.4 and 2020.3 LTS.
Thanks! Thatâs great news!
Restart unity. It worked for me
2022.2.13f1 Latest as of today
MonoScript is registered as both Editor and Runtime script!
It appeared after I added a script and then moved its location to an âEditorâ folder because it was an editor script
Restarting the Editor works!
Still getting the same error in 2021.3.24 LTS.
Iâm unsure what âfixedâ really means, as there are zero notes on the bug report about it. Does fixed mean you wonât get the error anymore? Youâll get an error but it should tell you the specific thing it is erroring about? Are you required to not put asmdefs in Editor folders? Lots of unanswered questions.