Пример #1
0
    //Get the Unity GameObject associated with the currentCloudAnchor
    public GameObject getCurrentAnchorGameObject()
    {
        GameObject currentAnchor    = null;
        var        anchorContainers = GameObject.FindGameObjectsWithTag("AnchorContainer");

        foreach (GameObject anchor in anchorContainers)
        {
            AnchorContainer anchorContainer = anchor.GetComponent <AnchorContainer>();
            if (anchorContainer.anchorID == currentCloudAnchor.Identifier)
            {
                currentAnchor = anchor;
                break;
            }
        }
        return(currentAnchor);
    }
Пример #2
0
    public GameObject getAnchorGameObject(CloudSpatialAnchor csa)
    {
        GameObject csaGameObject    = null;
        var        anchorContainers = GameObject.FindGameObjectsWithTag("AnchorContainer");

        foreach (GameObject anchor in anchorContainers)
        {
            AnchorContainer anchorContainer = anchor.GetComponent <AnchorContainer>();
            if (anchorContainer.anchorID == csa.Identifier)
            {
                csaGameObject = anchor;
                break;
            }
        }
        return(csaGameObject);
    }
Пример #3
0
    //we've hit a game object and we want the CloudSpatialAnchor associated with
    //it to go into currentCloudAnchor
    //then we switch the highlights to reflect that
    public async Task selectAnchor(GameObject objectHit)
    {
        var hitPosition      = objectHit.transform.position;
        var anchorContainers = GameObject.FindGameObjectsWithTag("AnchorContainer");

        debugText.text = "AnchorList Length: " + anchorContainers.Length;
        foreach (GameObject anchor in anchorContainers)
        {
            if (anchor.gameObject.transform.position == objectHit.transform.position)
            {
                AnchorContainer ac = anchor.gameObject.GetComponent <AnchorContainer>();
                if (ac != null)
                {
                    Debug.Log("Selected Anchor: " + ac.anchorID);
                    debugText.text = "Selected Anchor: " + ac.anchorID;
                    //shift anchors down
                    await updateCloudSpatialAnchorByID(ac.anchorID);
                }
            }
        }

        var previousPosition = previousCloudAnchor.GetPose().position;

        for (int i = 0; i < anchorContainers.Length; i++)
        {
            //if anchorcontainer is at location of the current anchor, this is the one we just found
            if (anchorContainers[i].gameObject.transform.position == hitPosition)
            {
                changeAnchorMaterials(anchorContainers[i], highlightMaterial);
            }

            //if we found the previous container, we need to reset this one so it isn't highlighted
            if (anchorContainers[i].gameObject.transform.position == previousPosition)
            {
                changeAnchorMaterials(anchorContainers[i], baseMaterial);
                //anchorContainers[i].gameObject.transform.GetChild(0).gameObject.GetComponent<Renderer>().material = baseMaterial;
            }
        }
    }