I have a parent of a script that has some serialized variables.
But I want a specific child script to have constant values for those values and disallow people from serializing them in the inspector.
How can I cancel the parent’s serialized fields within its child(and giving those fields constant values, or at least values within a script that are not serializable)
The normal way of doing this with inheritance would be to expose these data as properties or accessor methods, and have the child class override the parent’s version. Of course the whole “Unity inspector” aspect throws a wrench into things.
What is the use-case for this? A child is a specialization of its parent, so as a rule of thumb it should have the same properties, or slightly changed, specialized versions of those. Wanting to serialize something on a parent but not a child seems a bit weird to me at first glance, which does not mean there wouldnt be a viable use case for this tho. Still, a child is always also of the same type as its parent, so the same variable is literally that: the same thing. In order to change it you’ll have to overwrite it, or do some other trickery like reading the value and saving it so some non-serialized variable in the child. Then again, you basically implied that you’d have to do that to every variable of the child class, so there may be something wrong with your approach.