Esempio n. 1
0
        private void Start()
        {
            // Make sure we have all the components in the scene we need.
            anchorManager = WorldAnchorManager.Instance;
            if (anchorManager == null)
            {
                Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene.");
            }

            spatialMappingManager = SpatialMappingManager.Instance;
            if (spatialMappingManager == null)
            {
                Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene.");
            }

            if (anchorManager != null && spatialMappingManager != null)
            {
                anchorManager.AttachAnchor(this.gameObject, SavedAnchorFriendlyName);
            }
            else
            {
                // If we don't have what we need to proceed, we may as well remove ourselves.
                Destroy(this);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes all anchors from the scene and deletes them from the anchor store.
        /// </summary>
        public void RemoveAllAnchors()
        {
            SpatialMappingManager spatialMappingManager = SpatialMappingManager.Instance;

            // This case is unexpected, but just in case.
            if (AnchorStore == null)
            {
                Debug.LogError("remove all anchors called before anchor store is ready.");
            }

            WorldAnchor[] anchors = FindObjectsOfType <WorldAnchor>();

            if (anchors != null)
            {
                foreach (WorldAnchor anchor in anchors)
                {
                    // Don't remove SpatialMapping anchors if exists
                    if (spatialMappingManager == null ||
                        anchor.gameObject.transform.parent.gameObject != spatialMappingManager.gameObject)
                    {
                        anchorOperations.Enqueue(new AnchorAttachmentInfo()
                        {
                            AnchorName         = anchor.name,
                            GameObjectToAnchor = anchor.gameObject,
                            Operation          = AnchorOperation.Delete
                        });
                    }
                }
            }
        }
Esempio n. 3
0
 void StartPositioning()
 {
     gameState = GameState.Positioning;
     if (SpatialMapperObj != null)
     {
         spatialMapper = SpatialMapperObj.GetComponent <HoloToolkit.Unity.SpatialMappingManager>();
     }
     else
     {
         Debug.LogError("No Spatial Mapper Object defined in GameManager!!");
     }
     if (GoalObj != null)
     {
         kittenGoal = GoalObj.GetComponent <KittenGoal>();
         GoalObj.SetActive(true);
     }
     else
     {
         Debug.LogError("No Goal Object defined in GameManager!!");
     }
     if (SpawnerObj != null)
     {
         spawnerInstance = Instantiate(SpawnerObj);
     }
     if (spawnerInstance != null)
     {
         spawner           = spawnerInstance.GetComponent <KittenSpawner>();
         spawner.MaxSpawns = kittensToSpawn;
     }
     else
     {
         Debug.LogError("No Kitten Spawner defined in GameManager!!");
     }
     idleTimerReset = Time.time;
 }
Esempio n. 4
0
        /// <summary>
        /// Same functionality as RemoveAllAnchors. However, also deletes the gameObject
        /// the anchor was attached to as well. This is a custom method created
        /// for the purpose of this AugmentedObservatory application.
        /// </summary>
        public void RemoveAllObjectsWithAnchors()
        {
#if !UNITY_WSA || UNITY_EDITOR
            Debug.LogWarning("World Anchor Manager does not work for this build. RemoveAnchor will not be called.");
#else
            SpatialMappingManager spatialMappingManager = SpatialMappingManager.Instance;

            // This case is unexpected, but just in case.
            if (AnchorStore == null)
            {
                Debug.LogWarning("[WorldAnchorManager] RemoveAllAnchors called before anchor store is ready.");
            }

            var anchors = FindObjectsOfType <WorldAnchor>();

            if (anchors == null)
            {
                return;
            }

            for (var i = 0; i < anchors.Length; i++)
            {
                // Don't remove SpatialMapping anchors if exists
                if (spatialMappingManager != null && anchors[i].gameObject.transform.parent.gameObject == spatialMappingManager.gameObject)
                {
                    continue;
                }

                // Let's check to see if there are anchors we weren't accounting for.
                // Maybe they were created without using the WorldAnchorManager.
                if (!AnchorGameObjectReferenceList.ContainsKey(anchors[i].name))
                {
                    Debug.LogWarning("[WorldAnchorManager] Removing an anchor that was created outside of the WorldAnchorManager.  Please use the WorldAnchorManager to create or delete anchors.");
                    if (AnchorDebugText != null)
                    {
                        AnchorDebugText.text += string.Format("\nRemoving an anchor that was created outside of the WorldAnchorManager.  Please use the WorldAnchorManager to create or delete anchors.");
                    }
                }

                Destroy(anchors[i].gameObject);

                LocalAnchorOperations.Enqueue(new AnchorAttachmentInfo
                {
                    AnchorName         = anchors[i].name,
                    AnchoredGameObject = null,
                    Operation          = AnchorOperation.Delete
                });
            }
#endif
        }
        void Start()
        {
            // Get a reference to the spatial mesh
            Player          = GameObject.Find("SpatialMapping");
            mappingMaterial = Player.GetComponent <SpatialMappingManager>();

            // Create a new GestureRecognizer. Sign up for tapped events.
            gestureRecognizer = new GestureRecognizer();
            gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap);

            gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent;

            // Start looking for gestures.
            gestureRecognizer.StartCapturingGestures();
        }
Esempio n. 6
0
    void Start()
    {
        UISystems = new List <UISystem>();
        UISystems.Add(new UISystem()
        {
            id = 0, name = "MainCanvas", lastUI = true
        });
        UISystems.Add(new UISystem()
        {
            id = 1, name = "SpellbookCanvas", lastUI = false
        });
        UISystems.Add(new UISystem()
        {
            id = 2, name = "HowToCanvas", lastUI = false
        });
        UISystems.Add(new UISystem()
        {
            id = 3, name = "BattleCanvas", lastUI = false
        });
        UISystems.Add(new UISystem()
        {
            id = 4, name = "StartPlayingCanvas", lastUI = false
        });
        UISystems.Add(new UISystem()
        {
            id = 5, name = "RescanCanvas", lastUI = false
        });
        UISystems.Add(new UISystem()
        {
            id = 6, name = "LobbyCanvas", lastUI = false
        });

        UIStack = new Stack <UISystem>();
        scanner = GameObject.FindWithTag("Scanner").GetComponent <HoloToolkit.Unity.SpatialMappingManager>();

        openUI(5);
    }
 // Use this for initialization
 void Start()
 {
     // Get a reference to the spatial mapping mesh
     Player          = GameObject.Find("SpatialMapping");
     mappingMaterial = Player.GetComponent <SpatialMappingManager>();
 }