Error with SerializedMonoBehaviour on domain Backup (Unity 2021.2.16f1)

Issue #843 resolved
Jon Forshaw created an issue
  1. We are seeing an error for classes using SerializedMonoBehaviour (mainly making use of Dictionary), either after a recompile and/or reload assemblies.

    ```
    Objects are trying to be loaded during a domain backup. This is not allowed as it will lead to undefined behaviour!

    System.Reflection.MethodBase:Invoke (object,object[]) Sirenix.Serialization.OdinPrefabSerializationEditorUtility:ObjectIsPrefabInstance (UnityEngine.Object) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/OdinPrefabSerializationEditorUtility.cs:102) Sirenix.Serialization.UnitySerializationUtility:SerializeUnityObject (UnityEngine.Object,Sirenix.Serialization.SerializationData&,bool,Sirenix.Serialization.SerializationContext) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:621) Sirenix.OdinInspector.SerializedMonoBehaviour:UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize () (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/SerializedUnityObjects/SerializedMonoBehaviour.cs:44)
    ```

    It does not appear to have an adverse affect on the runtime (everything still works).

  2. This is rather a large project, but all classes using SerializedMonoBehaviour are showing the issue. The classes using SerializedMonoBehaviour are part of prefabs in the main selected scene. I can try to make a demo project if required.

  3. Screenshots don’t help.
  4. Using Unity 2021.2.16f1. (Updated from 2021.2.7f1 and earlier versions did not show the issue).
  5. We are using Odin 3.0.6.0. Have also tried with the latest 3.0.12.0 but the same issue was observed.
  6. We do not have “editor only enabled”.
  7. Seen on Windows 11.

Comments (6)

  1. Ignacio Martinez

    Same error on my project. Unity 2020.3.32f1

    We also have a SerializedMonoBehaviour class with a serialized 2-dimensional array:

    public class MatchPatternConfiguration : SerializedMonoBehaviour
    {
      [Serializable]
      public enum MatchPatternCell
      {
          None,
          Piece,
          HintPiece
      }
    
      [TableMatrix(HorizontalTitle = "Cells", DrawElementMethod = "DrawColoredCellElement",
      ResizableColumns = false, SquareCells = true)]
      public MatchPatternCell[,] Cells = new MatchPatternCell[3, 1];
    }
    

  2. Omer Perry

    Hi, it’s a bit of a stretch but worth trying:

    We keep seeing this error message in our project, and can’t seem to debug it because there is no stack trace.

    Many others are experiencing the same.

    We are not using Odin, but I thought it could be nice to hear what the fix was? No Unity representative had responded to the original thread.

    Thanks in advance.

  3. Log in to comment