Forums › 💬 NodeCanvas › ⚙️ Support › Unity2018.3.0f2 OnAfterDeserialize
I’m working migrate on our project to Unity 2018.3.0f2 from 2017 LTS. Today, I just open my prefab on the prefab mode(Nested Prefab feature added 2018.3), and meet a following error:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[Exception] InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread Object.EnsureRunningOnMainThread() /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153 Object.GetInstanceID() /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73 Object.IsNativeObjectAlive() /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182 Object.CompareBaseObjects() /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140 Object.op_Equality() /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:403 fsUnityObjectConverter.TryDeserialize() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/fsUnityObjectConverter.cs:70 fsSerializer.InternalDeserialize_5_Converter() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:886 fsSerializer.InternalDeserialize_4_Cycles() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:878 fsSerializer.InternalDeserialize_3_Inheritance() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:857 fsSerializer.InternalDeserialize_1_CycleReference() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:743 fsSerializer.TryDeserialize() Assets/SlotMaker/3rd Party/ParadoxNotion/CanvasCore/Common/Runtime/Serialization/Full Serializer/fsSerializer.cs:705 |
That prefab used to link animator but someday, someone delete animator, so index 2 is to be set 0 like this.
|
1 2 3 4 5 6 7 8 |
// prefab YAML _objectReferences: - {fileID: 0} - {fileID: 195826} - {fileID: 0} <------ this is occurred error - {fileID: 212245580321703842} |
Of course, I can fix to remove index 2 element, but doing before, I want to share this issues and talk about a few things.
First, in the ISerializationCallbackReceiver.OnAfterDeserialize especially new prefab edit mode, can not use object equals operator. See error log stack. fsUnityObjectConverter line 70, ‘reference == null’ is not allowed.
Second, this error log is only occurred in new prefab edit mode but runtime is not. Also runtime is not running deserialize right way without any logs.
Could you give me something advices?
Hello and sorry for the late reply due to xmas vacation.
No matter how much I try, I am still unable to somehow reproduce a similar error from coming up. With that said, does replacing reference == null with ReferenceEquals(reference, null) solves the problem on your end? Doing this bypass the custom UnityEngine.Object op_Equality comparer that seems to be the cause here.
Please let me know.
Thank you and happy new year.
Thanks and Happy New Year!
Sorry, I was blame problematic prefabs and found problems caused our developer refactoring prefabs by code before one years ago. Under normal circumstances, we checked that it was rearranged.
But, still nested prefab mode in Unity2018.3 also can be trigger next exception log:
|
1 2 3 |
ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'UnityEngine.Animator'. |
Reproducing steps below:
1. Create New Prefab and change to prefab mode
2. Add Blackboard/Animator components to new prefab root
3. Add Animator Blackboard Variable and link animator
4. Remove Animator
Thanks
Hello again,
Thanks a lot for the reproduction steps. I was able to identify and solve the problem.
To fix this, please open up ‘fsUnityObjectConverter’ and in ‘TryDeserialize’ method, ‘replace line of code:
if ( reference == null || storageType.RTIsAssignableFrom(reference.GetType()) ) {
with this:
if ( ReferenceEquals(reference, null) || storageType.RTIsAssignableFrom(reference.GetType()) ) {
Please let me know if that indeed works for you.
Thanks.
