I have class like -
[serializable]
public class DemoClass{
[SerializeField]
public GameObject gameObject;
}
I want to store data using serializable. Unity doc says GameObject is serializeField. But it gives Exception -
SerializationException: Type UnityEngine.GameObject is not marked as Serializable.
Anyone have idea about it ?
Add the tag
[Serializable]
before your class name:Documentation
Edit: ff you still want to serialize
GameObject
their is some plugins out there that allow to Serialize Unity Objects. See: Runtime Serialization for Unity