Exlcude fields from JsonUtility but still serialise them?


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?

Consider: [System.NonSerialized] public GameObject myGameObject;