Skip to content

[SRP] Fix issue when changing volume profiles at runtime with a script #5882

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 5 commits into from
Nov 4, 2021
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
3 changes: 3 additions & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added new DebugUI widget types: ProgressBarValue and ValueTuple
- Added common support code for FSR

### Fixed
- Fixed issue when changing volume profiles at runtime with a script (case 1364256).

## [13.1.0] - 2021-09-24

### Added
Expand Down
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void RefreshEffectListEditor(VolumeProfile asset)
{
m_ComponentList.Clear();

asset.Sanitize();

if (asset != null)
m_ComponentList.Init(asset, new SerializedObject(asset));
}
Expand Down
10 changes: 10 additions & 0 deletions com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,15 @@ internal int GetComponentListHashCode()
return hash;
}
}

/// <summary>
/// Removes any components that were destroyed externally from the iternal list of components
/// </summary>
internal void Sanitize()
{
for (int i = components.Count - 1; i >= 0; i--)
if (components[i] == null)
components.RemoveAt(i);
}
}
}