Skip to content

Conversation

@from2001
Copy link
Collaborator

Key changes

  • Refactored visionOS SDK setup.
    New logic for visionOS uses InstallPackageAndAssignLoaderForBuildTarget instead of EnableXRPlugin.
  • Refactored EnableXRPlugin for other SDKs.

Details

This pull request refactors and streamlines the SDK setup logic for various XR platforms in the Styly XR Rig project. The main focus is on improving package installation and loader assignment, unifying the way XR plugins are enabled, and cleaning up unused code. Special handling is also introduced for VisionOS, reflecting its unique requirements.

SDK Setup Refactoring and Unification:

  • Replaced usage of typeof(OpenXRLoader) with the string "UnityEngine.XR.OpenXR.OpenXRLoader" in all EnableXRPlugin calls, ensuring a consistent approach to enabling XR plugins across all SDK setup scripts. (SetupSdk_AndroidXR.cs, SetupSdk_MetaOpenXrSdk.cs, SetupSdk_PicoUnityOpenXrSdk.cs, SetupSdk_Template.cs, SetupSdk_ViveOpenXrPlugin.cs, SetupSdk_PcVrForDevelopment.cs) [1] [2] [3] [4] [5] [6]

  • Removed the call to PrepareSdkInstallation() from all InstallPackage() methods, simplifying the package installation process. (SetupSdk_AndroidXR.cs, SetupSdk_MetaOpenXrSdk.cs, SetupSdk_PicoUnityOpenXrSdk.cs, SetupSdk_Template.cs, SetupSdk_ViveOpenXrPlugin.cs, SetupSdk_PcVrForDevelopment.cs, SetupSdk_XrealSdk.cs) [1] [2] [3] [4] [5] [6] [7]

VisionOS-Specific Adjustments:

  • Changed the VisionOS package identifier to "com.unity.xr.visionos" and updated InstallPackage() to use the new InstallPackageAndAssignLoaderForBuildTarget method, which handles both package installation and loader assignment in one step. Also clarified that VisionOS setup differs from other SDKs and removed unnecessary code from the loader enabling step. (SetupSdk_PolySpatialVisionOS.cs) [1] [2]

Core Utility Enhancements:

  • Replaced PrepareSdkInstallation() with a new InstallPackageAndAssignLoaderForBuildTarget method in SetupSdkUtils.cs, using reflection to call Unity's internal API for installing packages and assigning loaders in one atomic operation. This improves reliability and maintainability of the SDK setup process. (SetupSdkUtils.cs)

Code Cleanup:

  • Removed the now-unused SetupSdk.cs file and its associated .meta file, as well as the related menu item for removing all SDK packages. (SetupSdk.cs, SetupSdk.cs.meta, SetupSdkMenu.cs) [1] [2] [3]

  • Minor import and code organization improvements, such as removing unused UnityEditor.Rendering import and adjusting debug menu items. (SetupSdkUtils.cs, SetupSdkMenu.cs) [1] [2]

@from2001 from2001 merged commit 4e2727e into develop Aug 31, 2025
@from2001 from2001 deleted the refactor/SdkSetup branch August 31, 2025 15:00
PrepareSdkInstallation();
if (AddUnityPackage(packageIdentifier)) { SessionState.SetBool(packageIdentifier, true); }
// Install package and assign loader
if (InstallPackageAndAssignLoaderForBuildTarget("com.unity.xr.visionos", "UnityEngine.XR.VisionOS.VisionOSLoader", BuildTargetGroup.VisionOS)) { SessionState.SetBool(packageIdentifier, true); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"com.unity.xr.visionos" and packageIdentifier are the same.

void Step1() // Enable the OpenXR Loader
{
EnableXRPlugin(BuildTargetGroup.Standalone, typeof(OpenXRLoader));
EnableXRPlugin(BuildTargetGroup.Android, "UnityEngine.XR.OpenXR.OpenXRLoader");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PCVR is standalone. Why the change to Android?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s just a mistake. I’ll fix it.

@from2001
Copy link
Collaborator Author

from2001 commented Sep 1, 2025

I fixed the wrong code in #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants