Skip to content

Commit 3c07308

Browse files
authored
WebXRCamera now removes event listeners OnDisable
There's an issue when an app destroys WebXRCamera instances (for example on scene changes) that causes NullPointer exceptions whenever the WebXRManager(WebXRSubsystem) triggers OnHeadsetUpdate and OnXRChange events
1 parent 6858535 commit 3c07308

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Packages/webxr/Runtime/Scripts/WebXRCamera.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ void OnEnable()
2828
WebXRManager.OnXRChange += OnXRChange;
2929
WebXRManager.OnHeadsetUpdate += OnHeadsetUpdate;
3030
}
31+
32+
void OnDisable()
33+
{
34+
WebXRManager.OnXRChange -= OnXRChange;
35+
WebXRManager.OnHeadsetUpdate -= OnHeadsetUpdate;
36+
}
3137

3238
void Update()
3339
{

0 commit comments

Comments
 (0)