Skip to content

Commit 7a1b512

Browse files
committed
WIP - Re-organize WebXRSubsystem
1 parent 59a9619 commit 7a1b512

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Runtime.InteropServices;
33
using AOT;
44
using UnityEngine;
5-
65
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
76
using UnityEngine.SubsystemsImplementation;
87
#endif
@@ -72,20 +71,6 @@ protected override void OnStart()
7271
Instance = this;
7372
InternalStart();
7473
}
75-
76-
protected override void OnStop()
77-
{
78-
if (Instance == null) return;
79-
Debug.Log("Stop " + nameof(WebXRSubsystem));
80-
Instance = null;
81-
}
82-
83-
protected override void OnDestroy()
84-
{
85-
if (Instance == null) return;
86-
Debug.Log("Destroy " + nameof(WebXRSubsystem));
87-
Instance = null;
88-
}
8974
#else
9075
public override void Start()
9176
{
@@ -95,26 +80,42 @@ public override void Start()
9580
Instance = this;
9681
InternalStart();
9782
}
83+
#endif
9884

85+
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
86+
protected override void OnStop()
87+
{
88+
if (Instance == null) return;
89+
Debug.Log("Stop " + nameof(WebXRSubsystem));
90+
Instance = null;
91+
}
92+
#else
9993
public override void Stop()
10094
{
10195
if (!_running) return;
10296
Debug.Log("Stop " + nameof(WebXRSubsystem));
10397
_running = false;
10498
Instance = null;
10599
}
100+
#endif
106101

102+
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
103+
protected override void OnDestroy()
104+
{
105+
if (Instance == null) return;
106+
Debug.Log("Destroy " + nameof(WebXRSubsystem));
107+
Instance = null;
108+
}
109+
#else
107110
protected override void OnDestroy()
108111
{
109112
if (!running) return;
110113
Debug.Log("Destroy " + nameof(WebXRSubsystem));
111114
_running = false;
112115
Instance = null;
113116
}
114-
115-
private bool _running;
116-
public override bool running => _running;
117117
#endif
118+
118119
private void UpdateControllersOnEnd()
119120
{
120121
if (OnHandUpdate != null)
@@ -225,12 +226,14 @@ private void UpdateXRCameras()
225226
}
226227
}
227228

228-
//private bool _running;
229-
//public override bool running => _running;
229+
#if !UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
230+
private bool _running;
231+
public override bool running => _running;
232+
#endif
230233

231234
private static WebXRSubsystem Instance;
232235

233-
internal void InternalStart()
236+
private void InternalStart()
234237
{
235238
#if UNITY_WEBGL
236239
Native.SetWebXREvents(OnStartAR, OnStartVR, UpdateVisibilityState, OnEndXR, OnXRCapabilities, OnInputProfiles);

0 commit comments

Comments
 (0)