Skip to content

Commit c93f57e

Browse files
Fix error when changing layer of Post Process Volume (#5275)
1 parent db9883a commit c93f57e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

com.unity.postprocessing/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88

99
### Fixed
1010
- Catch thrown errors in `PostProcessEffectRenderer`, preventing resources allocation leaks and crash (case 1221972)
11+
- Fixed error thrown when changing post process layer right after creation or before destruction.
1112

1213
## [3.1.1] - 2021-03-08
1314

com.unity.postprocessing/PostProcessing/Runtime/PostProcessManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ internal void UpdateVolumeLayer(PostProcessVolume volume, int prevLayer, int new
253253
{
254254
Assert.IsTrue(prevLayer >= 0 && prevLayer <= k_MaxLayerCount, "Invalid layer bit");
255255
Unregister(volume, prevLayer);
256+
Unregister(volume, newLayer);
256257
Register(volume, newLayer);
257258
}
258259

@@ -296,8 +297,8 @@ void Unregister(PostProcessVolume volume, int layer)
296297

297298
internal void Unregister(PostProcessVolume volume)
298299
{
299-
int layer = volume.gameObject.layer;
300-
Unregister(volume, layer);
300+
Unregister(volume, volume.previousLayer);
301+
Unregister(volume, volume.gameObject.layer);
301302
}
302303

303304
// Faster version of OverrideSettings to force replace values in the global state

com.unity.postprocessing/PostProcessing/Runtime/PostProcessVolume.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ public bool HasInstantiatedProfile()
164164
return m_InternalProfile != null;
165165
}
166166

167+
internal int previousLayer => m_PreviousLayer;
168+
167169
int m_PreviousLayer;
168170
float m_PreviousPriority;
169171
List<Collider> m_TempColliders;

0 commit comments

Comments
 (0)