// invoked by UserAnchorRemoved-event
    private void UserAnchorRemoved(ARUserAnchor anchor)
    {
        if (!arManager)
        {
            return;
        }

        MultiARInterop.MultiARData arData = arManager.GetARData();
        if (arData.allAnchorsDict.ContainsKey(anchor.identifier))
        {
            List <GameObject> anchoredObjs = arData.allAnchorsDict[anchor.identifier];
            arData.allAnchorsDict.Remove(anchor.identifier);

            foreach (GameObject anchoredObj in anchoredObjs)
            {
                if (anchoredObj && anchoredObj.transform.parent)
                {
                    GameObject parentObj = anchoredObj.transform.parent.gameObject;
                    anchoredObj.transform.parent = null;
                    anchoredObj.SetActive(false);

                    Destroy(parentObj);
                }
            }

            Debug.Log("Anchor removed: " + anchor.identifier);
        }
    }
Exemplo n.º 2
0
    void UnityARSessionNativeInterface_ARUserAnchorUpdatedEvent(ARUserAnchor anchorData)
    {
        modelInstance.transform.position = UnityARMatrixOps.GetPosition(anchorData.transform);
        modelInstance.transform.rotation = UnityARMatrixOps.GetRotation(anchorData.transform);

        Debug.LogFormat("Updated anchor: {0} | {1}", anchorData.identifier, modelInstance.transform.position.ToString("F2"));
    }
Exemplo n.º 3
0
        public void UpdateUserAnchor(ARUserAnchor arUserAnchor)
        {
            //Debug.Log("ARKitBridge: UpdateUserAnchor: arUserAnchor: " + arUserAnchor);

            userAnchor = arUserAnchor;
            SendEventData("UpdateUserAnchor");
        }
Exemplo n.º 4
0
 public void ExampleAddAnchor(ARUserAnchor anchor)
 {
     if (m_Clones.Contains(anchor.identifier))
     {
         Console.WriteLine("Our anchor was added!");
     }
 }
Exemplo n.º 5
0
        public void RemoveUserAnchor(ARUserAnchor arUserAnchor)
        {
            //Debug.Log("ARKitBridge: RemoveUserAnchor: arUserAnchor: " + arUserAnchor);

            userAnchor = arUserAnchor;
            SendEventData("RemoveUserAnchor");
        }
Exemplo n.º 6
0
        private static void WAnchorAdd(ARUserAnchor anchor)
        {
            Logger.log(Logger.Type.Info, "WAnchorAdd");

            if (!tracking)
            {
                Logger.log(Logger.Type.Info, "tracking paused. Ignore.");
                return;
            }

            if (!anchors.Add(anchor.identifier))
            {
                Logger.log(Logger.Type.Warning, "anchor was already added: {0}", anchor.identifier);
                return;
            }

            if (WAnchorAdded == null)
            {
                Logger.log(Logger.Type.Info, "no delegates for this event.");
                return;
            }

            Logger.log(Logger.Type.Info, "dispatch event.");
            WAnchor a = new WAnchor(anchor.identifier, UnityARMatrixOps.GetPose(anchor.transform));

            WAnchorAdded(a);
        }
Exemplo n.º 7
0
        private static void WAnchorUpdate(ARUserAnchor anchor)
        {
            Logger.log(Logger.Type.Info, "WAnchorUpdate");

            if (!tracking)
            {
                Logger.log(Logger.Type.Info, "tracking paused. Ignore.");
                return;
            }

            if (!anchors.Contains(anchor.identifier))
            {
                Logger.log(Logger.Type.Warning, "=> WAnchorAdd (tracking was probably off and just turned on).");
                WAnchorAdd(anchor);
                return;
            }

            if (WAnchorUpdated == null)
            {
                Logger.log(Logger.Type.Info, "no delegates for this event.");
                return;
            }

            Logger.log(Logger.Type.Info, "dispatch event.");
            WAnchor a = new WAnchor(anchor.identifier, UnityARMatrixOps.GetPose(anchor.transform));

            WAnchorUpdated(a);
        }
Exemplo n.º 8
0
    void Spawn(ARUserAnchor userAnchor)
    {
        var position = UnityARMatrixOps.GetPosition(userAnchor.transform);
        var rotation = UnityARMatrixOps.GetRotation(userAnchor.transform);

        Instantiate(prefab, position, rotation);
    }
 public void ExampleAddAnchor(ARUserAnchor anchor)
 {
     if (m_Clones.Contains(anchor.identifier))
     {
         Debug.Log("Our anchor was added!");
     }
 }
Exemplo n.º 10
0
 public void AnchorRemoved(ARUserAnchor anchor)
 {
     if (anchor.identifier.Equals(m_AnchorId))
     {
         UnityEngine.Object.Destroy(base.gameObject);
     }
 }
 public void AnchorRemoved(ARUserAnchor anchor)
 {
     if (m_Clones.Contains(anchor.identifier))
     {
         m_Clones.Remove(anchor.identifier);
         Debug.Log("AnchorRemovedExample: " + anchor.identifier);
     }
 }
Exemplo n.º 12
0
 public void AnchorRemoved(ARUserAnchor anchor)
 {
     if (m_Clones.Contains(anchor.identifier))
     {
         m_Clones.Remove(anchor.identifier);
         Console.WriteLine("AnchorRemovedExample: " + anchor.identifier);
     }
 }
Exemplo n.º 13
0
    void UnityARSessionNativeInterface_ARUserAnchorRemovedEvent(ARUserAnchor anchorData)
    {
        Transform child = GetChildForAnchorId(anchorData.identifier);

        child.gameObject.SetActive(false);

        Debug.LogFormat("Removed anchor: {0} | {1}", anchorData.identifier, child.position.ToString("F2"));
    }
Exemplo n.º 14
0
    void UnityARSessionNativeInterface_ARUserAnchorUpdatedEvent(ARUserAnchor anchorData)
    {
        Transform child = GetChildForAnchorId(anchorData.identifier);

        child.position = UnityARMatrixOps.GetPosition(anchorData.transform);
        child.rotation = UnityARMatrixOps.GetRotation(anchorData.transform);

        Debug.LogFormat("Updated anchor: {0} | {1}", anchorData.identifier, child.position.ToString("F2"));
    }
Exemplo n.º 15
0
        private void UpdateUserAnchor(ARUserAnchor _userAnchor)
        {
            ARKAnchor anchor;

            if (m_anchors.TryGetValue(_userAnchor.identifier, out anchor))
            {
                anchor.transform.position = _userAnchor.transform.GetColumn(3);
                anchor.transform.rotation = _userAnchor.transform.rotation;
            }
        }
Exemplo n.º 16
0
        private void UpdateUserAnchor(ARUserAnchor anchorData)
        {
            ARAnchor anchor;

            if (m_Anchors.TryGetValue(anchorData.identifier, out anchor))
            {
                anchor.transform.position = anchorData.transform.GetColumn(3);
                anchor.transform.rotation = anchorData.transform.rotation;
            }
        }
Exemplo n.º 17
0
 private void UserAnchorRemoved(ARUserAnchor anchor)
 {
     if (_userAnchors.ContainsKey(anchor.identifier))
     {
         _userAnchors.Remove(anchor.identifier);
     }
     if (_anchoredGameObjects.ContainsKey(anchor.identifier))
     {
         _anchoredGameObjects.Remove(anchor.identifier);
     }
 }
Exemplo n.º 18
0
    void UnityARSessionNativeInterface_ARUserAnchorAddedEvent(ARUserAnchor anchorData)
    {
        Transform child = GetChildForAnchorId(anchorData.identifier);

        child.position   = UnityARMatrixOps.GetPosition(anchorData.transform);
        child.rotation   = UnityARMatrixOps.GetRotation(anchorData.transform);
        child.localScale = new Vector3(PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleXKey(anchorData.identifier)), PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleYKey(anchorData.identifier)), PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleZKey(anchorData.identifier)));
        child.gameObject.SetActive(true);

        Debug.LogFormat("Added anchor: {0} | {1}", anchorData.identifier, child.position.ToString("F2"));
    }
Exemplo n.º 19
0
    private void UserAnchorAdded(ARUserAnchor anchor)
    {
        if (!_userAnchors.ContainsKey(anchor.identifier))
        {
            _userAnchors.Add(anchor.identifier, anchor);
        }

        if (_anchoredGameObjects.ContainsKey(anchor.identifier))
        {
            _anchoredGameObjects[anchor.identifier].transform.position = UnityARMatrixOps.GetPosition(anchor.transform);
            _anchoredGameObjects[anchor.identifier].transform.rotation = UnityARMatrixOps.GetRotation(anchor.transform);
        }
    }
Exemplo n.º 20
0
    void Spawn(ARUserAnchor userAnchor)
    {
        var position = UnityARMatrixOps.GetPosition(userAnchor.transform);
        var rotation = UnityARMatrixOps.GetRotation(userAnchor.transform);

        if (placedObj)
        {
            placedObj.transform.position = position;
            Debug.Log("オブジェクト移動");
        }
        else
        {
            Debug.Log("初回配置");
            placedObj = Instantiate(prefab, position, rotation);
        }
    }
Exemplo n.º 21
0
    void UnityARSessionNativeInterface_ARUserAnchorAddedEvent(ARUserAnchor anchorData)
    {
        modelInstance.transform.position = UnityARMatrixOps.GetPosition(anchorData.transform);
        modelInstance.transform.rotation = UnityARMatrixOps.GetRotation(anchorData.transform);

        Debug.LogFormat("Added anchor: {0} | {1}", anchorData.identifier, modelInstance.transform.position.ToString("F2"));

        if (PlayerPrefs.HasKey(playerPrefScaleXKey) && PlayerPrefs.HasKey(playerPrefScaleYKey) && PlayerPrefs.HasKey(playerPrefScaleZKey))
        {
            modelInstance.transform.localScale = new Vector3(PlayerPrefs.GetFloat(playerPrefScaleXKey), PlayerPrefs.GetFloat(playerPrefScaleYKey), PlayerPrefs.GetFloat(playerPrefScaleZKey));
        }

        // TODO
        modelInstance.SetActive(true);
        referenceImage.SetActive(false);
    }
Exemplo n.º 22
0
    void UnityARSessionNativeInterface_ARUserAnchorAddedEvent(ARUserAnchor anchorData)
    {
        // TODO: FIX ALL THIS SHIT.
        AnchoringFound = true;
        moveDeviceUI.SetActive(false);

        Transform child = GetChildForAnchorId(anchorData.identifier);

        child.position   = UnityARMatrixOps.GetPosition(anchorData.transform);
        child.rotation   = UnityARMatrixOps.GetRotation(anchorData.transform);
        child.localScale = new Vector3(PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleXKey(anchorData.identifier)), PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleYKey(anchorData.identifier)), PlayerPrefs.GetFloat(GlobalMapManager.Instance.GetPlayerPrefScaleZKey(anchorData.identifier)));

        // Fade in newly placed model
        FadeInModel(child);
        child.gameObject.SetActive(true);

        Debug.LogFormat("Added anchor: {0} | {1}", anchorData.identifier, child.position.ToString("F2"));
    }
Exemplo n.º 23
0
 private static void WAnchorRemove(ARUserAnchor anchor)
 {
     Logger.log(Logger.Type.Error, "WAnchorRemove not implemented");
 }
Exemplo n.º 24
0
 void UnityARSessionNativeInterface_ARUserAnchorAddedEvent(ARUserAnchor anchorData)
 {
     // Hide anchoring canvas now that anchoring is achieved
     anchoringUI.FadeOut();
 }
Exemplo n.º 25
0
 /* This is an example of how to tie a function to an AR event
  * ExampleAddAnchor is called after an anchor is added to the AR scene
  * The subscribing to an event part happens in Awake() */
 public void ExampleAddAnchor(ARUserAnchor anchor)
 {
     Debug.Log("Our anchor was added!");
 }
 // invoked by UserAnchorAdded-event
 private void UserAnchorAdded(ARUserAnchor anchor)
 {
     Debug.Log("Anchor added: " + anchor.identifier);
 }
Exemplo n.º 27
0
    void UnityARSessionNativeInterface_ARUserAnchorRemovedEvent(ARUserAnchor anchorData)
    {
        modelInstance.SetActive(false);

        Debug.LogFormat("Removed anchor: {0} | {1}", anchorData.identifier, modelInstance.transform.position.ToString("F2"));
    }
Exemplo n.º 28
0
 void UnityARSessionNativeInterface_ARUserAnchorAddedEvent(ARUserAnchor anchorData)
 {
     // Show tracker instrutions/text
     trackerInfo.SetActive(true);
 }
Exemplo n.º 29
0
 private void GameObjectAnchorUpdated(ARUserAnchor anchor)
 {
 }
Exemplo n.º 30
0
 /* This is an example of how to tie a function to an AR event
  * AnchorRemoved is called after an anchor is removed from the AR scene
  * The subscribing to an event part happens in Awake() */
 public void AnchorRemoved(ARUserAnchor anchor)
 {
     Debug.Log("AnchorRemovedExample: " + anchor.identifier);
 }