NonSerizalied and HideInInspector, why such similarity

Hey guys,

I have a a bunch of class instances I’m serializing.
The class contains a few gameobjects variables that cant be serialized easily, so I marked them with NonSerialized.
When I deserialize I assign models to the gameobjects variables that I marked as NonSerialized.
I need the gameobject variables from the class instance to be displayed in the inspector and saved when I enter/exit play mode. However because NonSerialized also hides them
from the inspector it clears the fields when I enter or exit the game.

Any ideas on how to get around it?

Not even a clue?

This can maybe help you but I don't think it's what you try to reach :/. http://answers.unity3d.com/questions/199691/nonserialized-vs-hideininspector-question.html Maybe you didn't undertand the meaning of each Properties (NonSerialized / HideInInspector / SerializedField ). At least if this can help you.

Thanks for your input liszto. Not being a programmer, I think its just my amateur approach that's to blame. The only solution I see at the moment is to create a new class and store the gameobjects there. If anyone has another solution I'd be glad to hear about it?

1 Answer

1

Unity’s default inspector works solely on the serialization system. It can’t show something that’s not serialized or not serializable. The only way is to write a custom inspector for your class. That way you can show whatever GUI you want. Of course if you “edit” things that aren’t serialized, changes will be lost on playmode change. If you serialize them yourself you are responsible for them.

Without more information that’s all i can say :wink:

Thanks for the tip! I actually have a bunch of class instances that are loaded into a custom inspector. Any idea on how I could modify the inspector to show the nonserialized values?