Пример #1
0
        ///<summary>
        /// Starts the restoration process.
        /// </summary>
        void StartRestore()
        {
            MLResult result = MLPersistentStore.Start();

            if (!result.IsOk)
            {
                SetError(result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                SetError(result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.GetAllPCFs(out _allPCFs, MaxPCFsToBindTo);
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                MLPersistentCoordinateFrames.Stop();
                SetError(result);
                enabled = false;
                return;
            }

            StartCoroutine(TryRestoreBinding());
        }
Пример #2
0
 /// <summary>
 /// Clean Up
 /// </summary>
 private void OnDestroy()
 {
     if (MLPersistentStore.IsStarted)
     {
         MLPersistentStore.Stop();
     }
     if (MLPersistentCoordinateFrames.IsStarted)
     {
         MLPersistentCoordinateFrames.Stop();
         MLPersistentCoordinateFrames.OnReady -= HandleReady;
     }
 }
        /// <summary>
        /// Clean Up
        /// </summary>
        void OnDestroy()
        {
            if (MLPersistentStore.IsStarted)
            {
                MLPersistentStore.Stop();
            }
            if (MLPersistentCoordinateFrames.IsStarted)
            {
                MLPersistentCoordinateFrames.Stop();
            }

            UnregisterPCFEventHandlers();
            StopAllCoroutines();
        }
Пример #4
0
        /// <summary>
        /// Shuts down the systems started in Start
        /// </summary>
        void OnDestroy()
        {
            if (MLPersistentCoordinateFrames.IsStarted)
            {
                MLPersistentCoordinateFrames.Stop();
            }

            if (MLPersistentStore.IsStarted)
            {
                MLPersistentStore.Stop();
            }

            PrivilegeRequester.OnPrivilegesDone -= HandlePrivilegesDone;
        }
        /// <summary>
        /// Clean up
        /// </summary>
        void OnDestroy()
        {
            if (MLPersistentStore.IsStarted)
            {
                MLPersistentStore.Stop();
            }
            if (MLPersistentCoordinateFrames.IsStarted)
            {
                MLPersistentCoordinateFrames.Stop();
            }

            foreach (GameObject go in _pcfObjs)
            {
                Destroy(go);
            }
        }
Пример #6
0
        /// <summary>
        /// Handler when MLPersistentCoordinateFrames becomes ready
        /// </summary>
        void HandleInitialized(MLResult status)
        {
            MLPersistentCoordinateFrames.OnInitialized -= HandleInitialized;

            if (status.IsOk)
            {
                CreateOrRestoreBinding();
            }
            else
            {
                Debug.LogErrorFormat("Error: MLPersistentCoordinateFrames failed to initialize, disabling script. Reason: {0}", status);
                MLPersistentStore.Stop();
                MLPersistentCoordinateFrames.Stop();
                Invoke("StartAPIs", 3);
            }
        }
Пример #7
0
        /// <summary>
        /// Start up
        /// Note: This requires the privilege to be granted prior to Start()
        /// </summary>
        void Start()
        {
            MLResult result = MLPersistentStore.Start();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("MLPersistentPoint failed starting MLPersistentStore, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                Debug.LogErrorFormat("MLPersistentPoint failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            if (string.IsNullOrEmpty(UniqueId))
            {
                Debug.LogWarning("Unique Id is empty will try to use game object's name. It's good to provide a unique id for virtual objects to avoid weird behavior.");
                if (string.IsNullOrEmpty(gameObject.name))
                {
                    SetError(new MLResult(MLResultCode.UnspecifiedFailure, "Either UniqueId or name should be non empty. Disabling component"));
                    enabled = false;
                    return;
                }
                UniqueId = gameObject.name;
            }
            else
            {
                gameObject.name = UniqueId;
            }

            if (MLPersistentCoordinateFrames.IsReady)
            {
                RestoreBinding(gameObject.name);
            }
            else
            {
                MLPersistentCoordinateFrames.OnReady += HandleReady;
            }
        }
Пример #8
0
        /// <summary>
        /// Attempts to start the MLPersistentStore and MLPersistentCoordinateFrames APIs
        /// </summary>
        void StartAPIs()
        {
            MLResult result = MLPersistentStore.Start();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("MLPersistentBehavior failed starting MLPersistentStore, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                Debug.LogErrorFormat("MLPersistentBehavior failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            if (string.IsNullOrEmpty(UniqueId))
            {
                Debug.LogWarning("Unique Id is empty will try to use game object's name. It's good to provide a unique id for virtual objects to avoid weird behavior.");
                if (string.IsNullOrEmpty(gameObject.name))
                {
                    Debug.LogError("Either UniqueId or name should be non empty. Disabling component");
                    enabled = false;
                    return;
                }
                UniqueId = gameObject.name;
            }

            if (MLPersistentCoordinateFrames.IsReady)
            {
                CreateOrRestoreBinding();
            }
            else
            {
                MLPersistentCoordinateFrames.OnInitialized += HandleInitialized;
            }
        }
        /// <summary>
        /// Start this instance.
        /// </summary>
        void Start()
        {
            MLResult result = MLPersistentStore.Start();

            if (!result.IsOk)
            {
                SetError("Failed to start persistent store. Disabling component");
                enabled = false;
                return;
            }
            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                SetError("Failed to start coordinate frames system. disabling component");
                enabled = false;
                return;
            }

            if (_representativePrefab == null)
            {
                SetError("Error: _representativePrefab must be set");
                enabled = false;
                return;
            }

            List <MLPCF> pcfList;

            result = MLPersistentCoordinateFrames.GetAllPCFs(out pcfList, int.MaxValue);
            if (!result.IsOk)
            {
                MLPersistentStore.Stop();
                MLPersistentCoordinateFrames.Stop();
                SetError(result.ToString());
                enabled = false;
                return;
            }

            TryShowingAllPCFs(pcfList);
        }