Example #1
0
 public void ExitSelection()
 {
     _animator.SetBool("selected", false);
     PlacementIndicator.SetActive(false);
     if (_anchor != null)
     {
         _anchor.destroyOnRemoval = false;
         _anchorManager.RemoveAnchor(_anchor);
         _anchorManager.anchorPrefab = null;
         _anchor = _anchorManager.AddAnchor(new Pose(transform.position, transform.rotation));
     }
 }
Example #2
0
        public void DeleteObject(string objectToDeleteGuid)
        {
            var objectToDelete = objectsData[objectToDeleteGuid];

            if (objectToDelete is null)
            {
                logger.LogError("DeleteObject()", "objectToDelete is null, it never should be");
                return;
            }

            logger.Log("DeleteObject()", $"obj: {objectToDelete}");

            ForEachChild(objectToDeleteGuid, (child) => {
                logger.Log("DeleteObject()", $"child: {child}");
                child.ParentingObject = objectToDelete.ParentingObject;
                child.Anchor          = objectToDelete.Anchor;
                child.GameObject.transform.SetParent(child.Anchor.transform);
                logger.Log("DeleteObject()", $"child after tuning: {child}");
            });

            var instanceId = objectToDelete.GameObject.GetInstanceID();

            if (reversedGameObjectsToDataMapping.ContainsKey(instanceId))
            {
                reversedGameObjectsToDataMapping.Remove(instanceId);
            }

            objectsData.Remove(objectToDeleteGuid);
            Object.Destroy(objectToDelete.GameObject);

            if (!IsAnchorStillInUse(objectToDelete.Anchor))
            {
                anchorManager.RemoveAnchor(objectToDelete.Anchor);
            }
        }
 private void RemoveLocalWorldAnchor()
 {
     if (WorldAnchorLocal != null)
     {
         DetachScene();
         ARAnchorManager.RemoveAnchor(WorldAnchorLocal);
     }
 }
Example #4
0
 public void Cleanup(ARAnchorManager arAnchorManager)
 {
     if ((arAnchorManager != null) && (arAnchor != null))
     {
         arAnchorManager.RemoveAnchor(arAnchor);
         arAnchor = null;
     }
 }
 private void ClearReferencePoints()
 {
     foreach (ARAnchor referencePoint in referencePoints)
     {
         arReferencePointManager.RemoveAnchor(referencePoint);
     }
     referencePoints.Clear();
     referencePointCount.text = $"Reference Point Count: {referencePoints.Count}";
 }
Example #6
0
 private void ClearAnchors()
 {
     foreach (ARAnchor anchor in anchors)
     {
         arAnchorManager.RemoveAnchor(anchor);
     }
     anchors.Clear();
     anchorPointCount.text = $"Anchor Point Count: {anchors.Count}";
 }
    public void RemoveAnchor()
    {
        if (_anchor == null)
        {
            return;
        }

        _anchorManager.RemoveAnchor(_anchor);
        _anchor = null;
    }
        public void RemoveImageAnchorFromImageName(string imageName)
        {
            if (trackedImageAnchors.ContainsKey(imageName))
            {
                // マーカー削除イベント
                this.OnRemoveImageAnchor?.Invoke(imageName);

                anchorManager.RemoveAnchor(trackedImageAnchors[imageName]);
                trackedImageAnchors.Remove(imageName);
            }
        }
Example #9
0
        public void Cleanup(ARAnchorManager arAnchorManager)
        {
#if WLT_ADD_ANCHOR_COMPONENT
            GameObject.Destroy(gameObject);
#else // WLT_ADD_ANCHOR_COMPONENT
            if ((arAnchorManager != null) && (arAnchor != null))
            {
                arAnchorManager.RemoveAnchor(arAnchor);
                arAnchor = null;
            }
#endif // WLT_ADD_ANCHOR_COMPONENT
        }
        public void RemoveImageAnchorFromImageName(string imageName)
        {
            if (trackedImageAnchors.ContainsKey(imageName))
            {
                Debug.LogFormat("ARTrackedImageAnchorManager :: ImageAnchor removed [{0}].", imageName);

                // マーカー削除イベント
                this.OnRemoveImageAnchor?.Invoke(imageName);

                anchorManager.RemoveAnchor(trackedImageAnchors[imageName]);
                trackedImageAnchors.Remove(imageName);
            }
        }
Example #11
0
    async public Task ResetSession()
    {
        foreach (ARAnchor anchor in aRAnchorManager.trackables)
        {
            aRAnchorManager.RemoveAnchor(anchor);
            Debug.Log("trying to remove anchor: " + anchor.trackableId);
        }
        currentCloudAnchor  = null;
        previousCloudAnchor = null;
        foundAnchors.Clear();
        spatialAnchorManager.StopSession();
        await spatialAnchorManager.ResetSessionAsync();

        await spatialAnchorManager.StartSessionAsync();
    }
Example #12
0
    public async Task ResetSession()
    {
        foreach (ARAnchor anchor in aRAnchorManager.trackables)
        {
            if (anchor == null)
            {
                break;
            }
            Log.debug($"-----ARFoundation removing {anchor.trackableId}");
            aRAnchorManager.RemoveAnchor(anchor);
            Log.debug("-----ARFoundation removed anchor ");
        }
        anchorManager.ClearCloudSpatialAnchorList();
        Log.debug($"-----SpatialAnchorManager Session is about to Reset:{anchorFirstTimeFound}");
        spatialAnchorManager.StopSession();
        await spatialAnchorManager.ResetSessionAsync();

        ConfigureSensors();
        await spatialAnchorManager.StartSessionAsync();

        Log.debug($"-----SpatialAnchorManager Reset Complete:{anchorFirstTimeFound}");
        Log.debug("Reset Anchor Lerper");
        FindObjectOfType <AnchorLerper>().ResetLerper();
    }
Example #13
0
    /// <summary>
    /// Spawn a portal at the given position. If a portal already exists, destroy the old one and create a new one.
    /// If the new portal is close to the existing portal, set new values for the existing portal.
    /// </summary>
    /// <param name="position">Position of a new AR Anchor that holds the position of the portal.</param>
    /// <param name="rotation">Rotation of the portal.</param>
    /// <param name="width">Width of the portal window.</param>
    /// <param name="height">Height of the portal window.</param>
    /// <returns>No return value.</returns>
    public void SpawnObject(Vector3 position, Quaternion rotation, float width, float height)
    {
        // Create an anchor that can be tracked from now on
        ARAnchor newAnchor = anchorManager.AddAnchor(new Pose(position, rotation));

        if (activeAnchor != null)
        {
            anchorManager.RemoveAnchor(activeAnchor);
        }
        activeAnchor = newAnchor;

        if (activePortal == null)
        {
            GameObject obj = Instantiate(objectToSpawn);
            obj.transform.parent        = activeAnchor.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.rotation      = rotation;

            activePortal = obj;

            // Set the augmentationCenter active and place behind the door
            if (!inside)
            {
                Vector3 offset = rotation * new Vector3(0, 0, 1);
                augmentationCenter.transform.position = position + offset;
                augmentationCenter.transform.rotation = rotation;
            }
            else
            {
                // Make sure the door is always facing into the augmented world
                obj.transform.Rotate(Vector3.up, 180.0f);
            }

            if (!created)
            {
                augmentationManager.Active = true;
                created = true;
            }

            // Only scale up the portal window, so child objects are not stretched
            GameObject portalWindow = activePortal.transform.Find("PortalWindow").gameObject;
            Vector3    scale        = new Vector3(width, height, 1);

            StartCoroutine(ScaleOverTime(portalWindow, spawnTime, scale));
        }
        else
        {
            float distance = Vector3.Distance(activePortal.transform.position, position);
            if (distance <= replacementDistance)
            {
                ReplacePortal(position, rotation, width, height);
            }
            else
            {
                Destroy(activePortal);
                activePortal = null; // Immidiate reset for recursive function call
                // Rerun the function to create a new portal
                SpawnObject(position, rotation, width, height);
            }
        }
    }
Example #14
0
 //remove previous anchor
 //this makes the camera movable again
 public void removeAnchor()
 {
     m_anchorManager.RemoveAnchor(m_anchor);
     m_anchor = null;
 }