Example #1
0
    void Update()
    {
        if (!TryGetTouchPosition(out Vector2 touchPosition))
        {
            return;
        }

        // if(placedGameObject != null)
        //     return;

        if (numOfPlaced == _arCloudAnchorManager.NUM_OF_ANCHOR)
        {
            return;
        }

        if (_arRaycastManager.Raycast(touchPosition, hits, UnityEngine.XR.ARSubsystems.TrackableType.PlaneWithinPolygon))
        {
            var hitPose = hits[0].pose;
            placedGameObjectTmp = Instantiate(placedPrefab, hitPose.position, hitPose.rotation);
            placedGameObjectList[_arCloudAnchorManager.numOfQueued] = placedGameObjectTmp;
            var anchor = _arAnchorManager.AddAnchor(new Pose(hitPose.position, hitPose.rotation));
            placedGameObjectList[_arCloudAnchorManager.numOfQueued].transform.parent = anchor.transform;

            // _arCloudAnchorManager.hi();
            // this won't host the anchor just add a reference to be later host it
            _arCloudAnchorManager.QueueAnchor(anchor);
            numOfPlaced++;
        }
    }