Fixed in Beta

References to Odin SerializabledScriptableObject get lost

babywka 1 month ago • updated by Lazlo Bonin (Lead Developer) 17 hours ago 14

SerializableScriptableObject is a part of Sirenix Odin

I have assigned in Variable 2 var:

  1. normal unity ScriptableObject
  2. SerializableScriptableObject

After code recompile a reference to SerializableScriptableObject is loosing

the video, if you cant, reproduce

Bolt Version:
Unity Version:
2018.3 stable
.NET Version:
Under Review

Hi Babywka,

Is there any console warning, message or error when reloading the scripts after making your change?

I'll ping the Odin developers too to see if anything special happens with their serialization here.

There's also a way to get debug data that might help us. After adding your Odin SO to the variables, click on the Cog icon on the component, then "Show Data...". Paste or send that file here so we can see what's being serialized by Bolt under the hood.

have created 2d instance of PlayerManager(SerializableScriptableObject) and the bug is not reproduces, don't know if it's possible that everything ok, but the file is corrupted in some way

Cannot Reproduce

Hm, strange. I'll mark this as Cannot Reproduce for now, but if you manage to consistently get it to happen, please comment again!

Heya, I think Im having a related issue.  My state machines randomly drop references to Odin SerializableScriptableObject and return standard Bolt "Value cannot be null" errors.

Seems to happen randomly when I make and compile code changes (arbitrarily, not to the object itself) and it doesn't drop all references, just some of them (even though they are assets generated from the same code).

My test setup uses a chain of states like this:

Still having the issue. Doesnt seem to affect standard scriptable objects, and happens on a fresh bolt install in an empty project in 2018.3.

Not sure if it helps, but here is the error:

[Serialization] System.ArgumentNullException: Value cannot be null.
Parameter name: unityObject
  at Sirenix.Serialization.UnitySerializationUtility.SerializeUnityObject (UnityEngine.Object unityObject, Sirenix.Serialization.SerializationData& data, System.Boolean serializeUnityFields, Sirenix.Serialization.SerializationContext context) [0x00009] in D:\Repositories\SirenixFramework\OdinSerializer\OdinSerializer\Unity Integration\UnitySerializationUtility.cs:382 
  at Sirenix.OdinInspector.SerializedScriptableObject.UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize () [0x00000] in D:\Repositories\SirenixFramework\OdinSerializer\OdinSerializer\Unity Integration\SerializedUnityObjects\SerializedScriptableObject.cs:40 
  at Ludiq.FullSerializer.fsSerializationCallbackReceiverProcessor.OnBeforeSerialize (System.Type storageType, System.Object instance) [0x00004] in C:\Users\lazlo\Projects\Bolt1\Package\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsISerializationCallbacks.cs:116 
  at Ludiq.FullSerializer.fsSerializer.Invoke_OnBeforeSerialize (System.Collections.Generic.List`1[T] processors, System.Type storageType, System.Object instance) [0x00004] in C:\Users\lazlo\Projects\Bolt1\Package\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:1153 
  at Ludiq.FullSerializer.fsSerializer.TrySerialize (System.Type storageType, System.Type overrideConverterType, System.Object instance, Ludiq.FullSerializer.fsData& data) [0x00013] in C:\Users\lazlo\Projects\Bolt1\Package\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:437 

UnityEngine.Debug:LogWarning(Object, Object)
Ludiq.Serialization:HandleResult(String, fsResult, Object) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:190)
Ludiq.Serialization:SerializeJson(fsSerializer, Object, Boolean) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:155)
Ludiq.Serialization:Serialize(Object, Boolean) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:80)
Ludiq.LudiqBehaviour:UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize() (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Unity/LudiqBehaviour.cs:23)

Was there a console error or warning after recompile, before the variable was cleared?

nope, any messages

before c# changes, 2 gameobjects have reference to same SerializedScriptableObject
then I made changes to LevelData.cs (SerializedScriptableObject) and one gameobject is ok and second is always losing reference with no messages in the console, always silent. Maybe I am doing something dumb? If you really want I can send the whole 1.2 Gb project
Fixed in Beta

I found a potential cause for this issue from the stack trace provided above and will have it fixed for v.1.4.1b5. Although I was  able to reproduce the stack trace posted above, I was not able to reproduce the reference disappearing.

My repro steps were, in 2018.3.1f1 + Bolt v.1.4.1b4:

  1. Create a UnityScriptableObject class deriving from UnityEngine.ScriptableObject
  2. Create an OdinScriptableObject class deriving from Sirenix.OdinInspector.SerializedScriptableObject
  3. Add [CreateAssetMenu] attributes to them and create one asset for each
  4. Create a new empty game object in an empty scene and add a Variables component
  5. Add one variable pointing to each type of scriptable object
  6. Force an assembly reload either via a code change or entering play mode



I will mark this as fixed for the next beta. Please try the attempted fix and let me know if the issue persists. Feel free to comment again if it does!