Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question ARTrackable.pending

Discussion in 'AR' started by jalamparambil_unity, Nov 22, 2022.

  1. jalamparambil_unity

    jalamparambil_unity

    Joined:
    Dec 16, 2021
    Posts:
    4
    Hi,
    I'm trying to define my own trackable which derives from ARTrackable<MyXRAnchorType, MyARAnchor>

    Now I want to be able to set the value for 'pending' when I enable the anchor and its manager is not present yet. Unfortunately the setting of the property is defined as 'internal'. How do I make this work?

    Thanks,
    Jimmy.
     
  2. jalamparambil_unity

    jalamparambil_unity

    Joined:
    Dec 16, 2021
    Posts:
    4
    Same question for deriving from ARTrackableManager and trying to access 'instance' property, which is internal.
     
  3. jalamparambil_unity

    jalamparambil_unity

    Joined:
    Dec 16, 2021
    Posts:
    4
    One solution I found was to make copies of those into my assembly under my own namespace and use those. Makes me feel icky though :)
     
  4. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,025
    I'm curious, why are you creating your own trackable and manager types? If we better understood your use case perhaps we could support you better in the future.

    I would strongly advise against cherry-picking ARTrackableManager into your assembly. As you likely discovered, ARTrackableManagers are tightly bound to the subsystems defined in the ARSubsystems namespace. If you create alternate managers for those subsystems, your managers will conflict with the AR Foundation managers, as both sets of managers will ultimately try to access and modify the same subsystem instance from Unity's XRLoader.

    A slightly better approach would be to copy the entire AR Foundation package as an embedded dependency and modify our source, but this is also a high-risk approach and likely to clash with future updates of AR Foundation. (Essentially at this point you would be responsible for maintaining your own fork of the package.)

    Another ill-advised plan would be to use reflection to set the internal properties that you can't access. (If future major version upgrades of AR Foundation change these properties, your reflection will break.) Edit: Runtime reflection may come with a significant performance cost on the API call as well as GC. You should profile the impacts of this strategy before committing to it.

    All of that said, my recommendation is to help us understand why you want to do this so we can design the API better for your use case.

    Edited Nov 23, 2022
     
    Last edited: Nov 23, 2022
    KyryloKuzyk likes this.