Hi. I'm having trouble figuring out the proper way to use ARPlaneManager.GetAllPlanes(). I need to collect the position of the AR Planes in my scene. More specific I need to update an output position that I need for object placement. I've pasted my update function below. When I run this on m device the currentPlanes.count keeps printing 0. Code (CSharp): private void Update() { if (planeDetectionIsLive) { arPlaneManager.GetAllPlanes(currentPlanes); Debug.Log("Plane Count: " + currentPlanes.Count); if (currentPlanes.Count > detectedPlanesCount) { if (!planeIsDetected) { planeIsDetected = true; } // Set plane position to last plane in currentPlanes planePosition = currentPlanes[-1].transform.position; detectedPlanesCount = currentPlanes.Count; Debug.Log("New plane is detected, amount of planes: " + detectedPlanesCount); } } }
I have a similar problem with the planeAdded, planeUpdated and planeRemoved events. They are never called. Code (CSharp): public void StartPlaneDetection() { if (arPlaneManager == null) { arPlaneManager = AR_SESSION_ORIGIN.GetComponent<ARPlaneManager>(); } arPlaneManager.enabled = true; planeDetectionIsLive = true; arPlaneManager.planeAdded += ArPlaneManager_PlaneAdded; Debug.Log("Start AR Plane Detection"); } void ArPlaneManager_PlaneAdded(ARPlaneAddedEventArgs obj) { Debug.Log("Plane is added with y pos: " + obj.plane.transform.position.y); }
I'm going to guess that GetAllPlanes is from an old version of AR Foundation. I believe to manipulate planes, it's best to use the Enumeration function here: https://docs.unity3d.com/Packages/c...rackable-managers.html#enumerating-trackables