Search Unity

Feature Request Implement a cache / pooling system for XRBaseInteractable custom reticle

Discussion in 'XR Interaction Toolkit and Input' started by R1PFake, May 5, 2021.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    540
    I would like to suggest to add a cache / pooling for the custom reticle in the XRBaseInteracable to avoid allocation on mobile.

    Currently there is a dictionary called m_ReticleCache but it does not really cache / reuse the object and will instantiate a new object every time you hover a object in AttachCustomReticle and destory it when you exit the hover of the object.

    Usually there will only be a few ray interactions per player, so a small "pool" which reuses the reticle would be useful. Maybe as an additional flag if pooling should be enabled or a pool size variable which is set to 0 by default to disable pooling and only people who want to enable it can set a different size.

    Im not sure if there are other parts in the framework which allocate objects, but I think it should be avoided if possible and in this case it would be easily possible to reuse the custom reticle object.