Search Unity

SpatialMapping.Instance is Null?

Discussion in 'VR' started by Lostlogic, Sep 11, 2017.

  1. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    I have a game object with the Spatial Mapping Collider and Spatial Mapping Renderer in my scene but when I try to access SpatialMapping via a script, it says it is NULL. Any idea why?

    SpatialMapping.Instance.DrawVisualMeshes = false;

    Throws:
    NullReferenceException: Object reference not set to an instance of an object
    GameStateManager.Update () (at Assets/Scripts/GameStateManager.cs:132)
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    It looks like you need to grab the game object with the spatial component then grab the collider or the renderer via script.
     
  3. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    Thanks for the help. It turns out I just had a rookie mistake of note including the proper #using. I was tired; hence, the stupid mistake. ;)
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558