浏览代码

Fix light intensity update and nullref on undo

/main
Antoine Lelievre 6 年前
当前提交
4beb4329
共有 2 个文件被更改,包括 16 次插入6 次删除
  1. 5
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  2. 17
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

5
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


// Update emissive mesh and light intensity when undo/redo
Undo.undoRedoPerformed += () => {
foreach (var h in m_AdditionalLightDatas)
h.UpdateAreaLightEmissiveMesh();
foreach (var hdLightData in m_AdditionalLightDatas)
if (hdLightData != null)
hdLightData.UpdateAreaLightEmissiveMesh();
};
}

17
com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs


[System.NonSerialized]
float oldLightColorTemperature;
// For light that used the old intensity system we update them
[System.NonSerialized]
bool needsIntensityUpdate = false;
// Runtime datas used to compute light intensity
Light _light;
Light m_Light

public void OnAfterDeserialize()
{
// If we are deserializing an old version, convert the light intensity to the new system
if (version == 1.0f)
if (version != currentVersion)
//TODO: test this
needsIntensityUpdate = true;
version = currentVersion;
}
}
private void OnEnable()
{
if (needsIntensityUpdate)
{
// Pragma to disable the warning got by using deprecated properties (areaIntensity, directionalIntensity, ...)
#pragma warning disable 0618
switch (lightTypeExtent)

break;
}
#pragma warning restore 0618
version = currentVersion;
}
}
}
正在加载...
取消
保存