Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved ARMeshManager - Hierarchy not allowed when using prefabs

Discussion in 'AR' started by Numa, May 18, 2021.

  1. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    Hi,

    There is a hierarchy check in ARMeshManager.cs to ensure it is a child of an ARSessionOrigin. That works fine unless your ARSessionOrigin is a prefab or part of a prefab. In that case you get this even with a valid hierarchy:
    upload_2021-5-18_17-1-24.png

    After looking into it a bit more, it looks like unity goes through ARMeshManager.OnValidate() and GetSessionOrigin() a few times when opening the prefab or pressing Play, but at one point the ARSessionOrigin game object shows activeInHierarchy = false, which makes GetSessionOrigin() return null and shows this beautiful popup.

    I just upgraded the packages to 4.1.7 from 4.1.1 and this started happening.
    Using Unity 2021.1.6f1 and 2020.1.16f1

    To reproduce, load the ClassificationMeshes scene from the arfoundation samples repo, and make the ARSessionOrigin object a prefab. You'll get the popup 2-3- times in a row.

    Is there a way around this besides not using prefabs?

    Thanks!
     
    Nereus248B likes this.
  2. Stout_pt

    Stout_pt

    Joined:
    Sep 26, 2018
    Posts:
    2
    Hi,

    I ran into a similar problem and fixed it by upgrading to ARFoundation 4.2.0

    Hope it helps!
     
  3. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    Ah thank you!
    Glad they fixed it in 4.2