Search Unity

Bug Script Compilation Bug in 2020.1

Discussion in 'Scripting' started by Rtyper, Nov 5, 2020.

  1. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Hi, I'm running into a weird bug concerning Unity 2020.1 here. I have a ScriptableObject-derived class called PhonemeSet that's used in my asset LipSync Pro, but Unity 2020.1 refuses to recognize the class properly.

    In a clean project with LipSync Pro downloaded straight from the Asset Store, 2019 shows the correct info for the class:
    upload_2020-11-5_14-23-9.png

    In 2020.1 however, the "No MonoBehaviour scripts in the file" notice shows up:
    upload_2020-11-5_14-23-39.png

    This leads to any instances of the object in the project being treated like the script failed to compile:
    upload_2020-11-5_14-27-8.png

    The project has absolutely no errors at all and the name of the file exactly matches the class name. All scripts (including this one!) have compiled just fine, Unity just seems to ignore this one. I've attached the script in question to test this out with. I changed nothing about the script between Unity versions, and I've tried reimporting, deleting the meta, deleting the library folder and doing a full project reimport etc. I've also tried renaming the class (and file), removing the subclasses (in case that was causing the issue) and deleting the file entirely and pasting the code into a new file with the same name - all to no avail.

    Any help here would be massively appreciated, as this is a pretty major bug that makes my asset unusable in Unity 2020!
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,748
  3. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Thanks for the links - definitely points to some issues with serialization in Unity (which I've run into before!) but this problem definitely seems to go deeper than that. There's been no renaming of the class, and it's not a one-time issue that invalidates existing ScriptableObjects - ALL instances of this ScriptableObject lose their connection to the class, even ones that are created later - Unity simply isn't recognising the class as a valid ScriptableObject.
     
  4. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Well, I've solved it but it still looks like a bug to me (as 2019.4 and earlier has no trouble with it). The problem line is
    #pragma warning restore 618
    - I'm using that along with
    #pragma warning disable 618
    at the top to suppress warnings about using that class' own deprecated code in data migration method in the same class. For some reason having that final warning restore line outside the namespace declaration (like the warning disable line is) causes Unity 2020.1 to fail to recognise the ScriptableObject as valid...

    Is there any chance someone from Unity can weigh in on this? Is this expected behaviour or an error?