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);
            }
        }
    private void Awake()
    {
        ImageTargetOffsetMaster.ImageTargets = ImageTargetOffsetSampleData.ImageTargets;
        _worldAnchorManager = GetComponent <WorldAnchorManager>();

        _disposable = new CompositeDisposable();
    }
        private void Start()
        {
            DetermineParent();
            if (SavedAnchorFriendlyName == string.Empty)
            {
                SavedAnchorFriendlyName = this.ObjectToPlace.name;
            }

            mainCamera = Camera.main;

            if (EnablePersistenceInWorldAnchor)
            {
                // Make sure we have all the components in the scene we need.
                anchorManager = WorldAnchorManager.Instance;
                if (anchorManager == null)
                {
                    Debug.LogError("The EnablePersistenceInWorldAnchor flag expects that you have a WorldAnchorManager component in your scene.");
                }
            }

            if (EnablePersistenceInWorldAnchor || Placement == PlacementOptions.ForceSpatialMapping || Placement == PlacementOptions.FreeAndSpatialMapping)
            {
                // Make sure we have all the components in the scene we need.
                spatialMappingManager = SpatialMappingManager.Instance;
                if (spatialMappingManager == null)
                {
                    Debug.LogError("The EnablePersistenceInWorldAnchor and Placement " + Placement.ToString() + " flags and expects that you have a SpatialMappingManager component in your scene.");
                }
            }

            if (anchorManager != null && spatialMappingManager != null)
            {
                anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName);
            }
        }
Exemple #4
0
        protected virtual 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(gameObject, SavedAnchorFriendlyName);
            }
            else
            {
                // If we don't have what we need to proceed, we may as well remove ourselves.
                Destroy(this);
            }

            if (PlaceParentOnTap)
            {
                if (ParentGameObjectToPlace != null && !gameObject.transform.IsChildOf(ParentGameObjectToPlace.transform))
                {
                    Debug.LogError("The specified parent object is not a parent of this object.");
                }

                DetermineParent();
            }
        }
    // Use this for initialization
    void Start()
    {
        ttsMgr = GetComponent <TextToSpeechManager>();
        if (ttsMgr == null)
        {
            Debug.LogError("TextToSpeechManager Required");
        }

        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);
            ttsMgr.SpeakText("Anchor Locked");
        }
        else
        {
            ttsMgr.SpeakText("Cannot Lock Anchor");
        }
    }
    public void OnInputClicked(InputClickedEventData eventData)
    {
        if (eventData.used)
        {
            return;
        }
        eventData.Use();

        // This debug statement helps to identify the scale in Unity of the augmented
        // columns and panels which we will need to accurate place the augmentations.

        // Debug.Log("Panel Object lossyScale: x: " + transform.lossyScale.x
        //  + " y: " + transform.lossyScale.y
        //  + " z: " + transform.lossyScale.z);

        // CustomAudioManager.Instance.PlayInputClicked();

        WorldAnchorManager anchorManager = WorldAnchorManager.Instance;

        if (anchorManager == null)
        {
            Debug.Log("Anchor manager not found, please attach it to scene!");
            return;
        }

        GameObject anchoredClone = null;

        anchoredClone = GameObject.Instantiate(PrefabsManager.Instance.fixedPanel
                                               , gameObject.transform.position
                                               , gameObject.transform.rotation);
        anchoredClone.transform.localScale = gameObject.transform.lossyScale;

        anchorManager.AttachAnchor(anchoredClone, gameObject.transform.parent.name);
        anchoredClone.GetComponent <FixedPanel>().RegisterImageTarget(gameObject.transform.parent.gameObject);
    }
Exemple #7
0
        public void TestGenerateAnchorNameFromParameter()
        {
            const string expected   = "AnchorName";
            var          gameObject = new GameObject();
            var          result     = WorldAnchorManager.GenerateAnchorName(gameObject, expected);

            Assert.That(result, Is.EqualTo(expected));
        }
Exemple #8
0
        private void Awake()
        {
            m_udpHelper = GameObject.FindObjectOfType <UDPHelper>();

            m_appState = GameObject.FindObjectOfType <HololensAppState>();

            m_worldAnchorManager = GameObject.FindObjectOfType <WorldAnchorManager>();
        }
Exemple #9
0
 private new void Start()
 {
     base.Start();
     _anchorStore = WorldAnchorManager.Instance;
     _anchorName  = "lola_" + target.gameObject.name;
     if (_anchorStore == null)
     {
         Debug.LogError("This scripts expects a WorldAnchorManager component to exist in the scene");
     }
 }
Exemple #10
0
 /**
  * Set the data for this info board.
  *
  * @param recognizedArtwork the recognized artwork information
  * @param placement         initial info board placement
  * @param artwork           data artwork for this info board
  * @param middlePoint       middle point of the recognized artwork
  */
 public void SetData(RecognizedArtwork recognizedArtwork, InfoBoardPlacement placement, Artwork artwork, Vector3 middlePoint)
 {
     this.anchorManager     = WorldAnchorManager.Instance;
     this.logger            = DebugLogger.Instance;
     this.infoCanvas        = InfoCanvas.Instance;
     this.arrows            = UIArrows.Instance;
     this.recognizedArtwork = recognizedArtwork;
     this.currentPlacement  = placement;
     this.artwork           = artwork;
     this.middlePoint       = middlePoint;
     StartCoroutine(Initialize());
 }
Exemple #11
0
    // Use this for initialization
    void Start()
    {
        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.");
        }
    }
Exemple #12
0
    void OnDestroy()
    {
        WorldAnchorManager anchorManager = WorldAnchorManager.Instance;

        if (anchorManager != null && imageTarget != null)
        {
            anchorManager.RemoveAnchor(imageTarget.name);
        }

        if (imageTarget != null)
        {
            imageTarget.SetActive(true);
        }
    }
        /**
         * Use this for initialization.
         */
        private void Start()
        {
            // Variable initialization (the other variables are set by a 'SetNewData' call)
            this.valid = false;

            // Get reference to other scripts in the scene
            this.anchorManager  = WorldAnchorManager.Instance;
            this.spatialMapping = SpatialMappingManager.Instance;
            this.logger         = DebugLogger.Instance;

            // Deactivate this script if necessary components are missing
            if ((this.infoBoard == null) || (this.scanningArea == null) || (this.artwork == null) || (this.anchorManager == null) || (this.spatialMapping == null) || (this.logger == null))
            {
                Debug.LogError("RecognizedArtwork: Script references not set properly.");
                this.enabled = false;
            }
        }
Exemple #14
0
        private void Start()
        {
            anchorManager = WorldAnchorManager.Instance;

            var spatialMappingManager = SpatialMappingManager.Instance;

            if (spatialMappingManager == null)
            {
                return;
            }

            mappingObserver = spatialMappingManager.Source as SpatialMappingObserver;
            if (mappingObserver != null)
            {
                mappingObserver.SurfaceAdded += SouvenirManager_OnMappingChanged;
            }
        }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        anchorManager = WorldAnchorManager.Instance;
        anchorName    = gameObject.name;
        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, anchorName);

            // ensures light UI is set at the proper position and rotation relative to parent

            foreach (Transform child in transform)
            {
                if (child.name == "HoloLightContainer(Clone)")
                {
                    var defaultHeight = child.localPosition.y;

                    child.localRotation = Quaternion.Euler(new Vector3(0, child.rotation.y, child.rotation.z));
                    child.localPosition = new Vector3(0, defaultHeight, 0);
                }
            }
            //if (gameObject.transform.GetChild(0)) {
            //    var child = this.gameObject.transform.GetChild(0);
            //    Debug.Log("here is child name: " + child.name);
            //    var defaultHeight = child.localPosition.y;

            //    child.localRotation = Quaternion.Euler(new Vector3(0, child.rotation.y, child.rotation.z));
            //    child.localPosition = new Vector3(0, defaultHeight, 0);
            //};
        }
        else
        {
            // If we don't have what we need to proceed, we may as well remove ourselves.
            Destroy(this);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        binAnchorName = string.Format("anchor_{0}", gameObject.name);

        worldAnchorManagerRef = WorldAnchorManager.Instance;
        if (PlayerPrefs.GetString("AR_exp_stop_aruwp_lib", "false").Equals("true"))
        {
            if (worldAnchorManagerRef != null)
            {
                worldAnchorManagerRef.AttachAnchor(gameObject, binAnchorName);
            }
            else
            {
                Destroy(this);
            }
        }
    }
    private void Start()
    {
        if (WhichDeviceManager.Instance.IsHoloLens())
        {
            if (ViveOrigin == null)
            {
                Debug.LogError("ViveOrigin cannot be null");
            }

            worldAnchorManager = GameObject.FindObjectOfType <WorldAnchorManager>();
            if (worldAnchorManager == null)
            {
                Debug.LogError("worldAnchorManager cannot be null");
            }

            LoadAnchorMarkers();
        }
    }
Exemple #18
0
    // Use this for initialization
    void Start()
    {
        CurrentState = ControlState.WaitingForAnchorStore;

        ttsMgr = GetComponent <TextToSpeechManager>();
        if (ttsMgr == null)
        {
            Debug.LogError("TextToSpeechManager Required");
        }

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

        WorldAnchorStore.GetAsync(AnchorStoreReady);
    }
        private void saveAnchor()
        {
            int data = SaveHandler.getFirstEmptyAnchorSpot();

            name = SaveHandler.saveDataWrapper.anchorData[data].id + "";
            SaveHandler.saveDataWrapper.anchorData[data].SpatialAnchorID = name;
            SaveHandler.saveDataWrapper.anchorData[data].unityLocation   = transform.position;
            SaveHandler.allAnchors.Add(gameObject);
            SaveHandler.Save();
            anchorData = SaveHandler.saveDataWrapper.anchorData[data];
            if (worldAnchorManager == null)
            {
                worldAnchorManager = GameObject.Find("AnchorManager").GetComponent <WorldAnchorManager>();
            }
            // add the anchor component
            #if !UNITY_EDITOR
            worldAnchorManager.AttachAnchor(gameObject, name);
            #endif
        }
        /// <summary>
        /// Initializes the component.
        /// </summary>
        private void Start()
        {
            // Temporary
            if (TargetGameObject == null)
            {
                TargetGameObject = gameObject;
            }

            if (AnchorId == null)
            {
                AnchorId = Guid.NewGuid().ToString();
            }

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

            var placeableComponent = gameObject.GetComponentInChildren <Placeable>(true);

            if (placeableComponent != null)
            {
                placeableComponent.TargetGameObject = TargetGameObject;
            }

            var rotatableComponent = gameObject.GetComponentInChildren <Rotatable>(true);

            if (rotatableComponent != null)
            {
                rotatableComponent.TargetGameObject = TargetGameObject;
            }

            var scalableComponent = gameObject.GetComponentInChildren <Scalable>(true);

            if (scalableComponent != null)
            {
                scalableComponent.TargetGameObject         = TargetGameObject;
                scalableComponent.ScalingLimitZoneEntered += AdjustmentBoxSetWarningColor;
                scalableComponent.ScalingLimitZoneExited  += AdjustmentBoxSetDefaultColor;
            }
        }
 private void AttachAnchor()
 {
     this.Manager = new WorldAnchorManager();
     this.Manager.AttachAnchor(this.gameObject);
 }
Exemple #22
0
 void Start()
 {
     anchorManager = WorldAnchorManager.Instance;
     SaveAnchor();
 }
Exemple #23
0
        /**
         * This method is called when the user has clicked on this GameObject.
         *
         * @param eventData     input click event data
         */
        public void OnInputClicked(InputClickedEventData eventData)
        {
            if ((this.size == PaladinSizes.Small) && (!this.interpolating))
            {
#if UNITY_EDITOR
                GameObject        paladin = Instantiate(this.gameObject);
                PaladinController ctrl    = paladin.GetComponent <PaladinController>();
                ctrl.ResetSword();
                ctrl.Grow(this.transform.parent, this.gameObject);
                this.gameObject.SetActive(false);
#else
                this.anchorManager = WorldAnchorManager.Instance;
                bool found = false;

                // Check if we have already instantiated a world anchor
                if (this.assetAnchor != null)
                {
                    GameObject        paladin = Instantiate(this.gameObject, this.assetAnchor.transform);
                    PaladinController ctrl    = paladin.GetComponent <PaladinController>();
                    ctrl.ResetSword();
                    ctrl.Grow(this.assetAnchor.transform, this.gameObject);
                    this.gameObject.SetActive(false);
                    found = true;
                }
                else if (this.anchorManager != null)
                {
                    // Check if a world anchor for this asset exists
                    UnityEngine.VR.WSA.Persistence.WorldAnchorStore store = this.anchorManager.AnchorStore;
                    if (store != null)
                    {
                        string[] ids = store.GetAllIds();
                        for (int index = 0; (index < ids.Length) && !found; index++)
                        {
                            if (ids[index].Equals(ANCHOR_ID))
                            {
                                this.assetAnchor = Instantiate(this.worldAnchorParent);
                                this.anchorManager.AttachAnchor(this.assetAnchor, ANCHOR_ID);
                                GameObject        paladin = Instantiate(this.gameObject, this.assetAnchor.transform);
                                PaladinController ctrl    = paladin.GetComponent <PaladinController>();
                                ctrl.ResetSword();
                                ctrl.Grow(this.assetAnchor.transform, this.gameObject);
                                this.gameObject.SetActive(false);
                                found = true;
                            }
                        }
                    }
                }

                // Try to query SpatialUnderstanding if a world anchor was not found
                if (!found && (this.anchorManager != null))
                {
                    SpatialUnderstanding suInstance = SpatialUnderstanding.Instance;
                    PlacementSolver      solver     = PlacementSolver.Instance;
                    if ((suInstance != null) && (solver != null) && InputManager.IsInitialized && (suInstance.ScanState == SpatialUnderstanding.ScanStates.Done) && suInstance.AllowSpatialUnderstanding)
                    {
                        InputManager.Instance.PushInputDisable();
                        solver.Query_OnFloor_NearPoint(this.transform.parent.position, false, this.HandlePlacementQuery);
                    }
                }
#endif
            }
            else if ((this.size == PaladinSizes.Big) && (!this.interpolating))
            {
                this.Die();
            }
        }
 // Start is called before the first frame update
 void Start()
 {
     worldAnchorManager = GameObject.Find("AnchorManager").GetComponent <WorldAnchorManager>();
     currentMode        = UIProperties.saveDataMode;
     StartCoroutine(CheckIfSaved());
 }
 public void Init(string id, WorldAnchorManager worldAnchorManager)
 {
     this.Id = id;
     this.worldAnchorManager = worldAnchorManager;
     this.gameObject.name    = "AnchorMarker [" + this.Id + "]";
 }
Exemple #26
0
 void Awake()
 {
     Instance = this;
 }
 public void Start()
 {
     SphereCollider     = GetComponent <SphereCollider>();
     worldAnchorManager = GameObject.Find("AnchorManager").GetComponent <WorldAnchorManager>();
 }
 void Awake()
 {
     MyManager = gameObject.GetComponent <WorldAnchorManager>();
 }
Exemple #29
0
        protected virtual void Start()
        {
            //状态机绑定


            ver1 = transform.position; ///////////////////

            Lerpfirst.OnUpdate = LerpUpdat;

            move.OnEnter  = OnInputClicked;
            move.OnUpdate = MoveUpdate;
            move.OnLeave  = OnInputClicked;

            rotate.OnEnter = EnterRotate;
            rotate.OnLeave = LeaveRoate;

            changecolor.OnLeave = LeaveChangColor;

            delet.OnEnter = Delet;

            //初始化状态
            // STATE = ido;

            selfmaterial = GetComponentInChildren <MeshRenderer>().material;

            Debug.Log(selfmaterial);
            //   WorldSpaceUI.Instance.e_tap += HitOnMe;

            // 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)
            {
                // If we are not starting out with actively placing the object, give it a World Anchor
                if (!IsBeingPlaced)
                {
                    //    anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName);
                }
            }
            else
            {
                // If we don't have what we need to proceed, we may as well remove ourselves.
                Destroy(this);
            }

            if (PlaceParentOnTap)
            {
                if (ParentGameObjectToPlace != null && !gameObject.transform.IsChildOf(ParentGameObjectToPlace.transform))
                {
                    Debug.LogError("The specified parent object is not a parent of this object.");
                }

                DetermineParent();
            }
            if (transform.Find("id_debuggertext") != null)
            {
                id_debuggertext       = transform.Find("id_debuggertext").GetComponent <TextMesh>();
                localpos_debuggertext = transform.Find("localpos_debuggertext").GetComponent <TextMesh>();
                id_debuggertext.text  = "我的ID::" + myID.ToString();
            }
        }