Search Unity

How to scan and detect only a single plane at a time in unity ARkit?

Discussion in 'AR' started by zyonneo, Sep 14, 2018.

  1. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    I was working on Vertical Plane detection in unity ARkit.The problem I faced is when I scan for vertical surfaces,there are many detected planes coming in.It gives a awkward look when opening the app.Is there a way to limit scan to pick only a single plane or single surface.

     
  2. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    Hi @zyonneo ,

    ARKit gives you all of the planes that it recognizes.

    In the ARPlaneAnchor class in C#, you will see that each instance will have an identifierStr property. The value of the identifierStr is guaranteed to be unique for each session.

    Register your own event callbacks for each of the following events to known then a new plane anchor is added/updated/removed:
    Code (CSharp):
    1. UnityARSessionNativeInterface.ARAnchorAddedEvent
    2. UnityARSessionNativeInterface.ARAnchorUpdatedEvent
    3. UnityARSessionNativeInterface.ARAnchorRemovedEvent
    You could keep a C# Dictionary with the ARPlaneAnchor.identifierStr value being the key and the ARPlaneAnchor being the value. Using this dictionary, you can choose what to do with all of the known ARPlaneAnchors in your scene.

    Todd