Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Feedback Improve "MonoScript is registered as both Editor and Runtime script!" error message

Discussion in 'Editor & General Support' started by Peter77, Oct 20, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,222
    The editor sometimes outputs the following error when an asset gets reimported:
    upload_2019-10-20_8-52-33.png

    Please improve this error by including the script name that is causing it. Some pointers how to fix this error would be helpful too.
     
    Mikael-H, nickeron, fherbst and 4 others like this.
  2. LW

    LW

    Joined:
    Jun 23, 2013
    Posts:
    22
    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?
     
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,353
    +1 moving around scripts started causing this for me. Not cool.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,222
    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. :confused:
     
  5. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    101
    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...
     
  6. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    460
    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.
     
    Last edited: Feb 5, 2020
    CristianOG and Longshilin like this.
  7. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    24
    As Lukasz mentioned, a bug report for this would be appreciated! :)
     
  8. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    20
    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
     
  9. mobychan

    mobychan

    Joined:
    Apr 7, 2013
    Posts:
    15
    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.
     
  10. jzylinski

    jzylinski

    Joined:
    Jul 29, 2019
    Posts:
    4
    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.
     
unityunity