Skip to content

Fix warning in HDAdditionalLightData OnValidate #885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
- Fixed an exception occuring when a camera doesn't have an HDAdditionalCameraData (1254383).
- Fixed ray tracing with XR single-pass.
- Fixed warning in HDAdditionalLightData OnValidate (cases 1250864, 1244578)

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,7 @@ internal Light legacyLight
internal MeshRenderer emissiveMeshRenderer { get; private set; }

#if UNITY_EDITOR
bool m_NeedsPrefabInstanceCheck = false;
bool needRefreshPrefabInstanceEmissiveMeshes = false;
#endif
bool needRefreshEmissiveMeshesFromTimeLineUpdate = false;
Expand Down Expand Up @@ -2292,6 +2293,14 @@ void LateUpdate()
#endif

#if UNITY_EDITOR

// If modification are due to change on prefab asset that are non overridden on this prefab instance
if (m_NeedsPrefabInstanceCheck && PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false))
{
needRefreshPrefabInstanceEmissiveMeshes = true;
}
m_NeedsPrefabInstanceCheck = false;

// Update the list of overlapping lights for the LightOverlap scene view mode
if (IsOverlapping())
s_overlappingHDLights.Add(this);
Expand Down Expand Up @@ -2499,13 +2508,9 @@ void OnValidate()
RefreshCachedShadow();

#if UNITY_EDITOR
// If modification are due to change on prefab asset that are non overridden on this prefab instance
if (PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false))
{
// As we cannot Create/Destroy in OnValidate, delay call to next Update
// To do this, wo set the same flag on prefab instances
needRefreshPrefabInstanceEmissiveMeshes = true;
}
// 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
// prefab instance. So we delay the check on next update (and before teh LateUpdate logic)
m_NeedsPrefabInstanceCheck = true;
#endif
}

Expand Down