Skip to content

Commit f1812fa

Browse files
Fix warning in HDAdditionalLightData OnValidate (#885)
* fix warning in HDAdditionalLightData OnValidate * Changelog * Avoid calling update Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
1 parent b1b2851 commit f1812fa

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
685685
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
686686
- Fixed an exception occuring when a camera doesn't have an HDAdditionalCameraData (1254383).
687687
- Fixed ray tracing with XR single-pass.
688+
- Fixed warning in HDAdditionalLightData OnValidate (cases 1250864, 1244578)
688689

689690
### Changed
690691
- Improve MIP selection for decals on Transparents

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,7 @@ internal Light legacyLight
15861586
internal MeshRenderer emissiveMeshRenderer { get; private set; }
15871587

15881588
#if UNITY_EDITOR
1589+
bool m_NeedsPrefabInstanceCheck = false;
15891590
bool needRefreshPrefabInstanceEmissiveMeshes = false;
15901591
#endif
15911592
bool needRefreshEmissiveMeshesFromTimeLineUpdate = false;
@@ -2292,6 +2293,14 @@ void LateUpdate()
22922293
#endif
22932294

22942295
#if UNITY_EDITOR
2296+
2297+
// If modification are due to change on prefab asset that are non overridden on this prefab instance
2298+
if (m_NeedsPrefabInstanceCheck && PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false))
2299+
{
2300+
needRefreshPrefabInstanceEmissiveMeshes = true;
2301+
}
2302+
m_NeedsPrefabInstanceCheck = false;
2303+
22952304
// Update the list of overlapping lights for the LightOverlap scene view mode
22962305
if (IsOverlapping())
22972306
s_overlappingHDLights.Add(this);
@@ -2499,13 +2508,9 @@ void OnValidate()
24992508
RefreshCachedShadow();
25002509

25012510
#if UNITY_EDITOR
2502-
// If modification are due to change on prefab asset that are non overridden on this prefab instance
2503-
if (PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false))
2504-
{
2505-
// As we cannot Create/Destroy in OnValidate, delay call to next Update
2506-
// To do this, wo set the same flag on prefab instances
2507-
needRefreshPrefabInstanceEmissiveMeshes = true;
2508-
}
2511+
// If modification are due to change on prefab asset, we want to have prefab instances to self-update, but we cannot check in OnValidate if this is part of
2512+
// prefab instance. So we delay the check on next update (and before teh LateUpdate logic)
2513+
m_NeedsPrefabInstanceCheck = true;
25092514
#endif
25102515
}
25112516

0 commit comments

Comments
 (0)