浏览代码

Merge pull request #1653 from Unity-Technologies/FixLightUnitUpgrade

Light unit upgrade workaround
/main
GitHub 6 年前
当前提交
309bef96
共有 2 个文件被更改,包括 21 次插入2 次删除
  1. 3
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 20
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

3
com.unity.render-pipelines.high-definition/CHANGELOG.md


## [3.0.0-preview]
### Fixed
- Fixed an issue where disabled light where not upgrade correctly to the new physical light unit system introduce in 2.0.5-preview
## [2.0.5-preview]

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


// 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()
{

正在加载...
取消
保存