I have a class that applies different visual effects depending on the time of day. The different times of day are represented as a nested class, like so:
public class TimeOfDayFadeInObjects : MonoBehaviour
{
[System.Serializable]
public class FadeObject
{
public string name;
public float maxOpacity = 1f;
//whole bunch more stuff
}
public List<FadeObject> objectsToFade;
//whole bunch more stuff
}
When I create a new instance of FadeObject in the Inspector, maxOpacity has it’s value set to 0. Is there any way to make it default to 1?
I have tried setting up a custom constructor for FadeObject, like so:
public FadeObject()
{
maxOpacity = 1f;
}
but this only seems to have the effect of bolding the values it touched in the inspector, not setting the default (I assume that Unity goes along and sets them all to a default after the constructor has run, but notices the divergence)