/// <summary>
        /// ARFoundation can discover platform anchors *after* ASA has provided the CloudSpatialAnchor to us
        /// When ARFoundation finds the platform anchor (usually within a frame or two) we will call the
        /// anchor located event.
        /// </summary>
        private void ProcessPendingEventArgs()
        {
            if (pendingEventArgs.Count > 0)
            {
                List <AnchorLocatedEventArgs> readyList = new List <AnchorLocatedEventArgs>();
                lock (pendingEventArgs)
                {
                    foreach (AnchorLocatedEventArgs args in pendingEventArgs)
                    {
                        string lookupValue = args.Anchor.LocalAnchor.GetPlatformKey();

                        if (pointerToReferencePoints.ContainsKey(lookupValue))
                        {
                            readyList.Add(args);
                        }
                    }

                    foreach (var ready in readyList)
                    {
                        pendingEventArgs.Remove(ready);
                    }
                }

                if (readyList.Count > 0)
                {
                    foreach (var args in readyList)
                    {
                        AnchorLocated?.Invoke(this, args);
                    }
                }
            }
        }
        void Start()
        {
            if (Text == null)
            {
                Text = GetComponent <Text>();
            }


            if (WorldSync == null)
            {
                WorldSync = FindObjectOfType <HoloWorldSync>();
            }

            if (AnchorLocated == null)
            {
                AnchorLocated = FindObjectOfType <AnchorLocated>();
            }

            // Suscribe to Anchor and Network events
            AnchorLocated.OnAnchorLocated += PromptShowToHoloLens;

            // First status
            if (Text != null)
            {
                Text.text = "Locating Floor...";
            }
        }
        /// <summary>
        /// Called when the <see cref="Session"/> <see cref="CloudSpatialAnchorSession.AnchorLocated">AnchorLocated</see> event is fired.
        /// </summary>
        /// <param name="sender">
        /// The <see cref="Session"/>.
        /// </param>
        /// <param name="args">
        /// The event data.
        /// </param>
        protected virtual void OnAnchorLocated(object sender, AnchorLocatedEventArgs args)
        {
            if (AnchorLocated == null)
            {
                return;
            }
#if UNITY_ANDROID || UNITY_IOS
            // if the anchor was located, wait for ARFoundation to notice the anchor we added
            // before firing the event
            if (args.Status == LocateAnchorStatus.Located)
            {
                lock (pendingEventArgs)
                {
                    pendingEventArgs.Add(args);
                }
            }
            else // otherwise there is no anchor for ARFoundation to find, so just fire the event
#endif
            {
                AnchorLocated?.Invoke(this, args);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Called when the <see cref="Session"/> <see cref="CloudSpatialAnchorSession.AnchorLocated">AnchorLocated</see> event is fired.
 /// </summary>
 /// <param name="sender">
 /// The <see cref="Session"/>.
 /// </param>
 /// <param name="args">
 /// The event data.
 /// </param>
 protected virtual void OnAnchorLocated(object sender, AnchorLocatedEventArgs args)
 {
     AnchorLocated?.Invoke(this, args);
 }