- Home /
How do i use CustomPropertyDrawer for NonSerialized properties?
For example i have
public abstract class A{}
[Serializable]public class B : A{}
[Serializable]public class C : A{}
[Serializable]public class D : A{}
And some class with container
[Serializable]
public class MyContainer : MonoBehaviour, ISerializationCallbackReceiver{
[NonSerialized]public List<A> myList;
public void OnBeforeSerialize() {
//my serialization
myList.Clear();
}
public void OnAfterDeserialize() {
//here i fill myList
}
}
So myList are filled with some abstract things and when unity serialize and deserialize this GameObject and this is abstract list anyway so it cant be serialized.
How do i draw this list in inspector in that case? Or how do i use CustomPropertyDrawer in that case?
Sure i can create CustomEditor for MyContainer and implement drawing of that list there. But it will be huge mess.
Answer by Krokozor · Jun 03, 2018 at 09:27 PM
Well. On the other thought. I can do what unity does. Don't do abstract class, add bunch of values to A class, add enum that tells "i am this type" and write UI using switches. But.. ugh... when does unity implement serialization of abstract classes? it just pain.
Your answer
Follow this Question
Related Questions
Min Attribute Not Working on Custom Property Drawer 0 Answers
Change texture import settings by script 0 Answers
Why UnityEngine.UI.Text color is not changed right away in the Editor? 1 Answer
Slideable Float Field in Custom Editor 3 Answers
Why is my unity editor script not saving changes to the actual script? 0 Answers