- Home /
Saving object references into json breaks on restarting the editor
I made an EditorWindow to edit something in my game and I'm using json to save some default data for that editor.
Here is how that class looks:
[System.Serializable]
class Defaults
{
public string leftThrusterBone;
public string rightThrusterBone;
public string downThrusterBone;
public string leftHandBone;
public string rightHandBone;
public ParticleSystem leftThrusterParticles;
public ParticleSystem rightThrusterParticles;
public ParticleSystem downThrusterParticles;
public ParticleSystem launchParticles;
public ParticleSystem dieParticles;
public AudioClip launchSound;
public AudioClip explosionSound;
public AudioClip landSound;
public AudioClip tapSound;
public AudioClip thrusterSound;
public WorldCustomizer world;
public RangedFloat hookLength;
public int hookAnimationLayer;
public float normalizedMiningTime = .5f;
public float hookAnimationTime = .6f;
public float fastSpeed = 1.5f;
public Vector3 center = Vector3.up * .5f;
public AnimationCurve animationSpeedCurve = AnimationCurve.Linear(0, 1, .1f, 1);
}
When I restart the editor, the default objects (ParticleSystems and AudioClips) are other random objects in the project. I checked the json file and it seems that the instanceID is changing.
I'm using JsonUtility to serialize it.
Is there something I'm missing? Or maybe there's an alternative that could work.
Your answer
Follow this Question
Related Questions
editor loading data from json error FileNotFoundException: Could not find file 1 Answer
Find instance of EditorWindow without creating new one? 2 Answers
close Editor Widnow Bug ? 0 Answers
Dock Game Window In Code? 1 Answer
why I Cant Add Multiple Objects to the "Object Field" in Editor Window? 3 Answers