- Home /
Problem solved. Set Dirty is only working with instances of classes that derive from Monobehavior
Set Dirty on class instance?
Hello, people! Here is the problem:
I have 3 classes and 1 editor for classA.
[Serializable]
ClassA : Monobehavior{
[SerializeField]
ClassB varb = new ClassB( );
}
[Serializable]
ClassB {
[SerializeField]
List<ClassC> listC = new List<ClassC>();
}
[Serializable]
ClassC{
[SerializeField]
List<Vector3> pos;
}
The thing is, when I change a value in Editor, I would attempt to go EditorUtility.SetDirty( (ClassA)target)); so that the changes are saved and won't be lost when I hit "Play"
But, how to I mark the variables in Class A, such as "varb", which represent instances of ClassB?
Saying EditorUtility.SetDirty( ((ClassA)target).varb ); will say :
Assets/Editor/NodeCounterEditor.cs(55,39): error CS1502: The best overloaded method match for UnityEditor.EditorUtility.SetDirty(UnityEngine.Object)' has some invalid arguments Casting ((ClassA)target).varb to Object will say Assets/Editor/NodeCounterEditor.cs(55,56): error CS0030: Cannot convert 'ClassB' expression to
UnityEngine.Object'
Please do not mention ScriptableObject, I cannot use it in my context
Thank you very much for your help!
Follow this Question
Related Questions
Serialize large array of class 0 Answers
nice Save but wrong load 0 Answers
Delete a serialized binary save file 2 Answers
making my classes usable? 1 Answer