// Use this for initialization
        void Start()
        {
            selfManipulate = GetComponent <SelfManipulate>();
            if (selfManipulate == null)
            {
                return;
            }
            //listen to manipulation events
            selfManipulate.onManipulationEnd.AddListener(onManipulationEnd);
            selfManipulate.onManipulationStart.AddListener(onManipulationStart);


            WorldAnchorManager.Instance.LoadAnchor(this.gameObject, onComplete);
        }
Esempio n. 2
0
        public void initialize(AppData.uniqueIDDevice deviceData, bool freshlyAddedDevice = false, bool isDeviceRefresh = false)
        {
            this.deviceData = deviceData;


            //baseadress
            baseAdress = deviceData.baseAdress;
            //name
            this.name = deviceData.baseAdress;

            HoverOffsetZ = deviceData.HoverOffsetZ;

            //self manipulate
            selfManipulate = GetComponent <SelfManipulate>();

            //anchor
            worldAnchorUser = GetComponent <WorldAnchorUser>();

            if (!isDeviceRefresh)//if this script is refreshed, we do not need to run this again
            {
                //Manipulation Events:
                selfManipulate.onManipulationStart.AddListener(onManipulationStart);
                selfManipulate.onManipulationEnd.AddListener(onManipulationEnd);



                //worldAnchorUser.linkedAnchor = deviceData.linkedAnchor;

                //start the process of restoring an anchor
                worldAnchorUser.WorldAnchorOperations();
            }


            //set the properties of this mqtt device
            //the position will be set relative to the parent "AllDevices"
            //TODO: is the positioning idea right?


            if (freshlyAddedDevice)
            {
                //set the device infront of the user
                this.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2f;

                //editor mode must be on
                selfManipulate.active = true;
            }


            //transform.localPosition= new Vector3(deviceData.posX, deviceData.posY, deviceData.posZ);//we have 1 anchor per device and dont need that


            if (isDeviceRefresh)
            {
                //we need to move, so detach
                worldAnchorUser.detachWorldAnchor();
            }

            transform.localEulerAngles = new Vector3(deviceData.rotX, deviceData.rotY, deviceData.rotZ);

            transform.localScale = new Vector3(deviceData.scaleX, deviceData.scaleY, deviceData.scaleZ);

            if (isDeviceRefresh)
            {
                //we need to move, so detach
                worldAnchorUser.attachWorldAnchor();
            }


            if (isDeviceRefresh)
            {
                Debug.Log(name + " refreshed");
            }
            else
            {
                Debug.Log(name + " initialized");
            }
        }