Search Unity

Feature Request Please make XRManagerSettings::loaders mutable in player

Discussion in 'AR/VR (XR) Discussion' started by Rib, Sep 9, 2020.

  1. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    Hi,

    To be able to support manually loading XR plugins at runtime in my application, (including support for command line options that allow users to disable or force the use of certain plugins) I'm currently duplicating some of the automatic loading logic inside XRManagerSettings due to the fact that there's no way for me to edit the list of loaders.

    Currently the loaders property is guarded like this in XRManagerSettings.cs:

    public List<XRLoader> loaders
    {
    get { return m_Loaders; }
    #if UNITY_EDITOR
    set { m_Loaders = value; }
    #endif
    }

    and so the ordering and choice of loaders is only mutable while in the editor.

    The loading logic is fairly simple so this isn't too much trouble but it seems like it would be preferable to still use XRManagerSettings even if I've disabled automatic plugin loading.
     
  2. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
  3. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    No, that isn't supported at runtime and that documentation should clarify that. The only way to modify the loader list is at edit/build time. Getting the loader list from management at runtime is meant to be only an informative thing.
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Clarification: Are you asking for support for changing the loader list to re-order or remove loaders, or are you asking to be able to add loaders to the list that were not there at build time?
     
  5. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    just to reorder or remove loaders - not trying to add loaders
     
  6. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    I don't think I'm the only person interested in being able to control the order of loading plugins at runtime or be able to disable plugins at runtime. For example please see here: https://snapandplug.com/xr-input-toolkit-2020-faq/ where someone has tried to document how this can be done (similarly also interpreting the official documentation to imply that some runtime control is possible).

    In my case I'm successfully able to handle this in my application by borrowing the logic from XRManagerSettings and effectively giving myself a mutable list to work with - but it seems a little excessive to have to do this only because that list isn't mutable.
     
  7. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    There's a reason it's not mutable by default, and that's because adding loaders at runtime is a dangerous and unsupported operation we don't want to make possible (or at least doable without work and knowing what you are doing).

    That said, can you file an issuetracker ticket for this so that we can at least get it internalized and possibly look at planning a more streamlined way of doing this?
     
  8. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    Right, blocking trying to add plugins sounds reasonable (expected even) but it seems like it should be possible to take a runtime approach for allowing re-ordering/removal but disallow addition to the list.

    Maybe XManagerSettings could maintain a private, immutable whitelist of available loaders that's essentially set in stone at build time, and then just throw an exception in the setter if you try to include a loader that's not in the whiltelist?

    I've tried submitting a 'bug' via the editor tool, since I couldn't see how else to file an issue - hopefully that works, thanks.
     
  9. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Do you have the ID for that?
     
  10. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    "Case 1276511" if that's the right ID?
     
  11. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Thank you.
     
    Rib likes this.