Search Unity

Resolved Unloading Additive Scene

Discussion in 'XR Interaction Toolkit and Input' started by Redtail87, Nov 18, 2020.

  1. Redtail87

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    125
    Hey,

    I'm running into an issue when unloading an additive scene with a single XR Rig and interaction manager.

    If you interact with an object via XRDirectInteractor in the additively loaded scene, then unload it later, the XRDirectInteractor will throw a bunch of null refs since its validTargets list still contains the objects from the unloaded scene.

    For now I have implemented this dirty hack to fix the issue, but is there a better way to support this?

    Code (CSharp):
    1. public class XRDirectInteractorCustom : XRDirectInteractor
    2.     {
    3.         public override void GetValidTargets(List<XRBaseInteractable> validTargets)
    4.         {
    5.             base.validTargets.RemoveAll(x => ObjectUtil.IsNull(x));
    6.             base.GetValidTargets(validTargets);
    7.         }
    8.     }
    Thanks.
     
    chris-massie likes this.
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    231
    A fix for this is currently in progress and will likely be in the next version.
     
    Redtail87 likes this.
  3. Redtail87

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    125
    Awesome, thanks for the update.
     
  4. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    Going to resolve this thread!