Ejemplo n.º 1
0
    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));
    }
Ejemplo n.º 2
0
    private void OnPlaneRemoved(InsightARPlaneAnchor plane)
    {
        GameObject go = GameObject.Find(plane.identifier);

        m_AllPlanes.Remove(go);
        GameObject.Destroy(go);
    }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
    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));
    }
Ejemplo n.º 6
0
    private void OnPlaneUpdated(InsightARPlaneAnchor plane)
    {
        GameObject go = GameObject.Find(plane.identifier);

        UpdatePlaneWithAnchorTransform(go, plane);
    }