Search code examples
unity-game-enginegoogle-project-tangoplanegameobject

Getting a GameObject from Plane


I'd like to know if there's an easy way to represent a Plane as a GameObject.

I'm using the FindPlane method from Tango's PointCloud that returns a Plane and I'd like to create a GameObject from that Plane so I can see it in my 3d world.

Thx :)


Solution

  • the API only returns the Unity Plane data structure, that data structure doesn't have a game object associated with it.

    In order to create the game object at the plane's location, you will need to instantiate the game object programmatically like this:

    // Tango Find Plane function in the TangoPrefabs/Scripts/TangoPointCloud.cs
    FindPlane(cam, pos, maxPixelDist, minInlierPercentage, ref planeCenter, ref Plane plane);
    Instantiate(targetGameobject, planeCenter, Quaternion.identity);