Exlcude fields from JsonUtility but still serialise them?
Hi,
So to generate a game save for my game I am converting certain components of gameobjects to JSON so I can store the information load in again.
Some of my class have properties that I need to be visible in the inspector (so serialisable) so that I can set their values but they are not needed in the game save so I want JsonUtility to ignore them.
For example, I have a ThrusterModule and it has an "acceleration" field. This field is set in the inspector for the prefab but as it's part of the prefab it does not need to be part of the game save. This module has other fields, such as "thrustEnabled" that is not set in the prefab and changes throughout the game and so needs to be saved in the game save. So I need to have fields such as "acceleration" serialised so it's visible in the inspector for me to set it's value. But I need it non-serialised so that JsonUtility will ignore it when I generate my game save.
Is there some way to mark a field to be still serialised but ignored by JsonUtlity?
Answer by Monsoonexe · Feb 21 at 12:11 AM
Consider: [System.NonSerialized] public GameObject myGameObject;
Your answer
Follow this Question
Related Questions
Arrays not serializing 1 Answer
JsonUtility and Arrays - JSON must represent an object type. 0 Answers
Argument Exception: J SON must represent an object type. Serialization list of objects 0 Answers
wrapping object name around my .FromJson string?? 0 Answers
Json item list serialization problem 0 Answers