Skip to content

Commit 6b8fcb4

Browse files
authored
Merge pull request #139 from De-Panther/bug_fix_windows_il2cpp
Fixed errors when building for other platforms using IL2CPP
2 parents 8ff0ba3 + 1b55912 commit 6b8fcb4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Packages/webxr/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Changed
1212
- Optimization for JavaScript to C# communication.
1313

14+
### Fixed
15+
- Errors when building for other platforms using IL2CPP.
16+
1417
### Removed
1518
- Custom JavaScript dispatch events from the WebGLTemplates.
1619

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,16 @@ private void UpdateXRCameras()
158158

159159
private void InternalStart()
160160
{
161+
#if UNITY_WEBGL
161162
Native.set_webxr_events(OnStartAR, OnStartVR, OnEndXR, OnXRCapabilities, OnInputProfiles);
162163
Native.InitControllersArray(controllersArray, controllersArray.Length);
163164
Native.InitHandsArray(handsArray, handsArray.Length);
164165
Native.InitViewerHitTestPoseArray(viewerHitTestPoseArray, viewerHitTestPoseArray.Length);
165166
Native.InitXRSharedArray(sharedArray, sharedArray.Length);
167+
#endif
166168
}
167169

170+
#if UNITY_WEBGL
168171
private static class Native
169172
{
170173
[DllImport("__Internal")]
@@ -198,6 +201,7 @@ public static extern void set_webxr_events(Action<int, float, float, float, floa
198201
Action<string> on_xr_capabilities,
199202
Action<string> on_input_profiles);
200203
}
204+
#endif
201205

202206
internal WebXRState xrState = WebXRState.NORMAL;
203207

@@ -332,41 +336,51 @@ public static void OnEndXR()
332336

333337
public void ToggleAR()
334338
{
339+
#if UNITY_WEBGL
335340
if (capabilities.canPresentAR)
336341
{
337342
Native.ToggleAR();
338343
}
344+
#endif
339345
}
340346

341347
public void ToggleVR()
342348
{
349+
#if UNITY_WEBGL
343350
if (capabilities.canPresentVR)
344351
{
345352
Native.ToggleVR();
346353
}
354+
#endif
347355
}
348356

349357
public void StartViewerHitTest()
350358
{
359+
#if UNITY_WEBGL
351360
if (xrState == WebXRState.AR && !viewerHitTestOn)
352361
{
353362
viewerHitTestOn = true;
354363
Native.ToggleViewerHitTest();
355364
}
365+
#endif
356366
}
357367

358368
public void StopViewerHitTest()
359369
{
370+
#if UNITY_WEBGL
360371
if (xrState == WebXRState.AR && viewerHitTestOn)
361372
{
362373
viewerHitTestOn = false;
363374
Native.ToggleViewerHitTest();
364375
}
376+
#endif
365377
}
366378

367379
public void HapticPulse(WebXRControllerHand hand, float intensity, float duration)
368380
{
381+
#if UNITY_WEBGL
369382
Native.ControllerPulse((int)hand, intensity, duration);
383+
#endif
370384
}
371385

372386
void GetMatrixFromSharedArray(int index, ref Matrix4x4 matrix)

0 commit comments

Comments
 (0)