I've got a class like this:
And so when I attach this to a GameObject, the default value displayed is 5.
Then, let's say I have a subclass where I would like the default value of this variable to be some value other than 5.
The above does not work, but is there a way to get this sort of behavior? My particular case is that each of several subclasses share a "speed" variable, but they each require this value to be different by default.
asked Aug 19 '11 at 04:48 PM
Subclasses have full inheritance, so you wouldnt need to declare it again. You can either assign it in a Start method as you would any other variable, or the easier way is to set its value in the inspector.
(Note that private variables are not inherited).
answered Aug 19 '11 at 05:56 PM