serializationunity-game-enginebeta

Unity 5.4 - broken serialization


It seems as if Unity 5.4 has a serialization issue:

public class InputManager : MonoBehaviour 
{
    [SerializeField] private MyObject obj;
}

[Serializable]
public class MyObject¨
{
}

results in :

InvalidOperationException: The operation is not possible when moved past all properties (Next returned false)

Am I doing it wrong?


Solution

  • You should put some public fields in the class you want to serialize. If it's empty, or only has private or protected fields, there's nothing to serialize. The error message could have been better (something like "nothing to serialize" instead of the one you're getting).