Have I discoverd a Unity bug? Or am I doing something not allowed?
When I wrap an object in a generic wrapper struct, and then use that struct as a field in a MonoBehavior, the object being wrapped doesn't seem to serialize correctly.
For example, the Debug.Log() line in this example will always print "False", even when no Material is assigned.
{
public Wrapper<Material> test;
}
[Serializable]
public struct Wrapper<T> : ISerializationCallbackReceiver where T : class
{
[SerializeReference]
public T target;
public void OnBeforeSerialize()
{
Debug.Log(target == null);
}
public void OnAfterDeserialize()
{
}
}```