How do you use serialized values at creation?

For instance, let’s say I have a class called “PlayerStats” which is attached as part of some player monobehaviour. “PlayerStats” has one int field representing maximum health. This is serialized so it is editable in the inspector. I also have a variable called current health (not serialized), and I want this variable to start out at the value of the maximum health input by the inspector. The default constructor is, of course, called during deserialization upon starting the game so it seems that the logical thing to do would be to set the “current health” to the “maximum health” in the default constructor. However, if I try and access the “maximum health” field during the constructor, it does not yet have its serialization information, so at the time of this call the “maximum health” will still be equal to 0 and not whatever was input in the inspector. These values are not set until AFTER the constructor is completed. What is the proper way to do something like this?

Do NOT EVER use or implement the constructor for MonoBehaviours. Use either Awake() or Start().

Awake is called when the behavior is first created (probably what you want to use for your case)

Start() is called the first frame a GameObject is visible (after awake).