|
|
|
|
|
|
|
|
|
|
// This structure contains all the old values for every recordable fields from the HD light editor
|
|
|
|
// so we can force timeline to record changes on other fields from the LateUpdate function (editor only)
|
|
|
|
struct TimelineWorkaournd |
|
|
|
struct TimelineWorkaround |
|
|
|
{ |
|
|
|
public float oldDisplayLightIntensity; |
|
|
|
public float oldSpotAngle; |
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
// We need these old states to make timeline and the animator record the intensity value and the emissive mesh changes (editor-only)
|
|
|
|
[System.NonSerialized] |
|
|
|
TimelineWorkaournd timelineWorkaround; |
|
|
|
TimelineWorkaround timelineWorkaround; |
|
|
|
#endif
|
|
|
|
|
|
|
|
// For light that used the old intensity system we update them
|
|
|
|
|
|
|
// If we are deserializing an old version, convert the light intensity to the new system
|
|
|
|
if (version <= 1.0f) |
|
|
|
{ |
|
|
|
// Note: We can't access to the light component in OnAfterSerialize as it is not init() yet,
|
|
|
|
// so instead we use a boolean to do the upgrade in OnEnable().
|
|
|
|
// However if the light is not enabled, the light is not upgraded.
|
|
|
|
// To solve this issue we add a callback below that will force OnEnable() to upgrade the light.
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
EditorApplication.update += EditorOnEnableWorkaround; |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
// See comment above, this is a workaround to upgrade Disabled light correctly.
|
|
|
|
void EditorOnEnableWorkaround() |
|
|
|
{ |
|
|
|
OnEnable(); |
|
|
|
EditorApplication.update -= EditorOnEnableWorkaround; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
{ |
|
|
|