private GameObject CreatePlaneInScene(InsightARPlaneAnchor arPlaneAnchor) { GameObject plane; if (_planePrefab != null) { plane = GameObject.Instantiate(_planePrefab); plane.transform.localScale = Vector3.one; plane.transform.localPosition = Vector3.zero; plane.transform.localRotation = Quaternion.identity; if (hasObjectCreated) { if (plane.GetComponent <MeshRenderer>() != null) { plane.GetComponent <MeshRenderer>().enabled = false; } if (plane.GetComponent <BoxCollider>() != null) { plane.GetComponent <BoxCollider>().enabled = false; } } } else { plane = new GameObject(); //put in a blank gameObject to get at least a transform to manipulate } plane.name = arPlaneAnchor.identifier; return(UpdatePlaneWithAnchorTransform(plane, arPlaneAnchor)); }
private void OnPlaneRemoved(InsightARPlaneAnchor plane) { GameObject go = GameObject.Find(plane.identifier); m_AllPlanes.Remove(go); GameObject.Destroy(go); }
private void OnPlaneAdded(InsightARPlaneAnchor plane) { Debug.Log("-ar- OnPlaneAdded:PlaneAnchor(" + plane.center.ToString("f2") + "," + plane.rotation.ToString("f2") + plane.identifier + ")"); GameObject go = CreatePlaneInScene(plane); m_AllPlanes.Add(go); }
private GameObject UpdatePlaneWithAnchorTransform(GameObject plane, InsightARPlaneAnchor arPlaneAnchor) { if (plane == null) { return(null); } //do coordinate conversion from ARKit to Unity plane.transform.localPosition = arPlaneAnchor.center; plane.transform.localRotation = arPlaneAnchor.rotation; plane.transform.localScale = arPlaneAnchor.extent; return(plane); }
private GameObject CreatePlaneInScene(InsightARPlaneAnchor arPlaneAnchor) { GameObject plane; if (_planePrefab != null) { plane = GameObject.Instantiate(_planePrefab); plane.transform.localScale = Vector3.one; plane.transform.localPosition = Vector3.zero; plane.transform.localRotation = Quaternion.identity; } else { plane = new GameObject(); //put in a blank gameObject to get at least a transform to manipulate } plane.name = arPlaneAnchor.identifier; return(UpdatePlaneWithAnchorTransform(plane, arPlaneAnchor)); }
private void OnPlaneUpdated(InsightARPlaneAnchor plane) { GameObject go = GameObject.Find(plane.identifier); UpdatePlaneWithAnchorTransform(go, plane); }