Skip to content

Can't add or remove PXR_Loader through AssignLoader and RemoveLoader functions on XR Settings #31

@keith-vstream

Description

@keith-vstream

I have a build script for building out different versions of our apps for different XR platforms (Pico/OpenXR/Quest/Cardboard).

Since updating to this git version of the Pico SDK when attempting to use the AssignLoader and RemoveLoader functions of the XRPackageMetadataStore Pico no longer gets added or removed

[MenuItem("Build/Set SDK/Pico XR")]
public static void SetPicoXRSDK() {
    XRGeneralSettingsPerBuildTarget buildTargetSettings = null;
    EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings);
    XRGeneralSettings settings = buildTargetSettings.SettingsForBuildTarget(BuildTargetGroup.Android);

    XRPackageMetadataStore.RemoveLoader(settings.Manager, typeof(Unity.XR.Oculus.OculusLoader).FullName, BuildTargetGroup.Android);
    XRPackageMetadataStore.RemoveLoader(settings.Manager, typeof(Google.XR.Cardboard.XRLoader).FullName, BuildTargetGroup.Android);

    // the following doesn't work, but used to with previous versions of Pico SDK
    bool didthiswork = XRPackageMetadataStore.AssignLoader(settings.Manager, typeof(Unity.XR.PXR.PXR_Loader).FullName, BuildTargetGroup.Android);
    // it returns true as if it worked, but the Pico Loader is still unassigned in the XR Plugin Management window of Project Settings
    Debug.Log($"Did this work? {didthiswork}");

}

And I'm seeing the same problem with setting it directly on the Settings Manager:

[MenuItem("Build/Log Loader Names")]
public static void LogLoaderNames() {
    XRGeneralSettingsPerBuildTarget buildTargetSettings = null;
    EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings);
    XRGeneralSettings settings = buildTargetSettings.SettingsForBuildTarget(BuildTargetGroup.Android);

    XRLoader lastLoader = null;
    foreach (XRLoader loader in settings.Manager.activeLoaders) {
        Debug.Log(loader.name);
        Debug.Log(loader.GetType().FullName);
        lastLoader = loader;
    }
    if(lastLoader != null) {
        settings.Manager.TryRemoveLoader(lastLoader);
        bool diditwork = XRPackageMetadataStore.RemoveLoader(settings.Manager, lastLoader.GetType().FullName, BuildTargetGroup.Android);
        Debug.Log($"Did it work? {diditwork}");
    }
}

Notably it's also stopped working with the Unity OpenXR Loader but works fine with Oculus and Cardboard Loaders so I'm not sure where the issue is, but upgrading just the Pico SDK from a local folder with v2.5.3 to this git repo url has broken the functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions