Skip to content

Commit 52e5176

Browse files
committed
WIP - Re-organize WebXRSubsystem
1 parent 48d0e24 commit 52e5176

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ public WebXRSubsystemDescriptor()
1717
providerType = typeof(WebXRSubsystem.Provider);
1818
}
1919
}
20+
#else
21+
public class WebXRSubsystemDescriptor : SubsystemDescriptor<WebXRSubsystem>
22+
{
23+
}
24+
#endif
2025

26+
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
2127
public abstract class WebXRSubsystemProvider : SubsystemProvider<WebXRSubsystem> { }
2228

2329
public class WebXRSubsystem : SubsystemWithProvider<WebXRSubsystem, WebXRSubsystemDescriptor, WebXRSubsystemProvider>
30+
#else
31+
public class WebXRSubsystem : Subsystem<WebXRSubsystemDescriptor>
32+
#endif
2433
{
34+
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
2535
public class Provider : WebXRSubsystemProvider
2636
{
2737
public override void Start() { }
@@ -37,8 +47,22 @@ private static void RegisterDescriptor()
3747
id = typeof(WebXRSubsystem).FullName
3848
});
3949
}
50+
#else
51+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
52+
private static void RegisterDescriptor()
53+
{
54+
var res = SubsystemRegistration.CreateDescriptor(new WebXRSubsystemDescriptor()
55+
{
56+
id = typeof(WebXRSubsystem).FullName,
57+
subsystemImplementationType = typeof(WebXRSubsystem)
58+
});
59+
if (res)
60+
Debug.Log("Registered " + nameof(WebXRSubsystemDescriptor));
61+
else Debug.Log("Failed registering " + nameof(WebXRSubsystemDescriptor));
62+
}
63+
#endif
4064

41-
internal static WebXRSubsystem Instance;
65+
#if UNITY_XR_MANAGEMENT_4_3_1_OR_NEWER
4266
protected override void OnStart()
4367
{
4468
if (Instance != null) return;
@@ -61,25 +85,6 @@ protected override void OnDestroy()
6185
Instance = null;
6286
}
6387
#else
64-
public class WebXRSubsystemDescriptor : SubsystemDescriptor<WebXRSubsystem>
65-
{
66-
}
67-
68-
public class WebXRSubsystem : Subsystem<WebXRSubsystemDescriptor>
69-
{
70-
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
71-
private static void RegisterDescriptor()
72-
{
73-
var res = SubsystemRegistration.CreateDescriptor(new WebXRSubsystemDescriptor()
74-
{
75-
id = typeof(WebXRSubsystem).FullName,
76-
subsystemImplementationType = typeof(WebXRSubsystem)
77-
});
78-
if (res)
79-
Debug.Log("Registered " + nameof(WebXRSubsystemDescriptor));
80-
else Debug.Log("Failed registering " + nameof(WebXRSubsystemDescriptor));
81-
}
82-
8388
public override void Start()
8489
{
8590
if (running) return;
@@ -107,8 +112,6 @@ protected override void OnDestroy()
107112

108113
private bool _running;
109114
public override bool running => _running;
110-
111-
private static WebXRSubsystem Instance;
112115
#endif
113116
private void UpdateControllersOnEnd()
114117
{
@@ -220,6 +223,11 @@ private void UpdateXRCameras()
220223
}
221224
}
222225

226+
//private bool _running;
227+
//public override bool running => _running;
228+
229+
private static WebXRSubsystem Instance;
230+
223231
internal void InternalStart()
224232
{
225233
#if UNITY_WEBGL

0 commit comments

Comments
 (0)