Cannot Reproduce

Serialization problem with Odin variable

William 4 years ago updated 3 years ago 14


I ran into a problem with Odin Inspector: I added few variables that are of a type that inherits from Odin's SerializedMonoBehaviour. The variables showed up properly, however when I make the object into a prefab and apply the changes, the references are lsot on Play: any way to deal with this?


Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

To be clear here:

  • Which object do you make a prefab, the one with the variables or the one the variables refer to?
  • Are the references lost on the prefab itself, or on instances of the prefab?

The one with the variables that is, the prefab contains the gameobject that has the variable component, and the variables of course reference to objects within the prefab, nothing from the outside.

The references are lost on the instances of the prefab, but I'm afraid I did not check on the prefab itself.

Ok, please have a look! Note that if those references are scene references, a prefab cannot hold them in its variables. That is because any non-scene object in Unity cannot hold any scene-bound reference, it's not a Bolt issue/bug.

Yes I know, but those are object references though, not scene ones. 

Seems like the reference is kept on the prefab, but lost on Play on the instances. 

I also found out that the reference is lost only if it is used in the graph, but not if it's only declared in the variables

One last thing: the type is shown as "null" during play, and null is kept when exiting play.

actually, after play it looks like the type and the reference is also lost on the prefab, even though it references an object within the prefab.

Ok, and can you confirm that this only happens from references derived from Odin's SerializedMonoBehaviour?

that's the only one I tested, but I can try with other types as well!

Cannot Reproduce

Please comment or reopen this thread when you've isolated the issue!

I am having a similar issue but with Odin's SerializedScriptableObject.  To reproduce:

1. Create Macro

2. Create Instance of normal scriptable object

3. Drag reference to normal scriptable object instance into graph

4. Attach macro to object, push play, it works.

5. Change scriptable object to inherit from SerializedScriptableObject

6. Update units

7. Push play, reference is set to null

Pending Review

Thank you for adding the repro steps, I'll look into it further.

Cannot Reproduce

Hi genbod and William! I tried reproducing this issue but I cannot.

  • Unity 2017.4.3f1
  • Bolt v.1.4.0f4
  • Odin 2.0.0

Here is my script:

using Sirenix.OdinInspector;
using UnityEngine;
public class OdinScriptableObject : SerializedScriptableObject

Here is my graph, stored in a macro and attached to a flow machine in my scene:

And my project structure:

Once I hit play, the reference stays in place and properly gets logged.

If you have clearer reproduction steps, please let me know!

For me the setup involved having variables being of a type that derived from SerializedMonobehaviour, and using it in a similar way as yours. But my issue appeared only on prefab instances: for the prefab itself the values were properly saved (and referenced objects within the prefab of course). It's been quite some time, so I'll try to find some time soon to try and reproduce it precisely