private IEnumerator Start()
        {
            //hooks:
            Transmission.Instance.OnOldestPeerUpdated.AddListener(HandleOldestPeerUpdated);
            Transmission.Instance.OnGlobalStringChanged.AddListener(HandleGlobalStringChanged);
            Transmission.Instance.OnGlobalStringsReceived.AddListener(HandleGlobalStringsReceived);

            //refs:
            _camera = Camera.main.transform;

            //system start-ups:
            if (!MLPersistentCoordinateFrames.IsStarted)
            {
                MLPersistentCoordinateFrames.Start();

                //wait for MLPersistentCoordinateFrames to localize:
                while (!MLPersistentCoordinateFrames.IsLocalized)
                {
                    yield return(null);
                }

                //establish shared pcf:
                MLPersistentCoordinateFrames.FindClosestPCF(_camera.position, out _anchorPCF, MLPersistentCoordinateFrames.PCF.Types.MultiUserMultiSession);
                if (_anchorPCF == null)
                {
                    //keep looking:
                    yield return(new WaitForSeconds(_pcfSearchTimeout));
                }

                //hooks:
                MLPersistentCoordinateFrames.OnLocalized        += HandleLocalized;
                MLPersistentCoordinateFrames.PCF.OnStatusChange += HandlePCFStatusChange;
            }
        }
Пример #2
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());
        }
        /// <summary>
        /// Starts the persistence systems, MLPersistentStore and MLPersistentCoordinateFrames
        /// </summary>
        IEnumerator StartPersistenceSystems()
        {
            if (!MLPersistentStore.IsStarted)
            {
                MLResult result = MLPersistentStore.Start();
                if (!result.IsOk)
                {
                    SetProgress(TEXT_FAILED_TO_START_PERSISTENT_STORE);
                    _state = State.CritialError;
                }
                else
                {
                    while (true)
                    {
                        result = MLPersistentCoordinateFrames.Start();

                        if ((MLPassableWorldResult)result.Code == MLPassableWorldResult.LowMapQuality ||
                            (MLPassableWorldResult)result.Code == MLPassableWorldResult.UnableToLocalize)
                        {
                            SetProgress(string.Format(TEXT_RETRY_PCF, result, _retryIntervalInSeconds));
                            yield return(new WaitForSeconds(_retryIntervalInSeconds));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            OnStartPersistentSystemComplete();
        }
Пример #4
0
    void StartPCFS()
    {
        MLResult result = MLPersistentCoordinateFrames.Start();

        if (!result.IsOk)
        {
            if (result.Result == MLResult.Code.PrivilegeDenied)
            {
                Instantiate(Resources.Load("PrivilegeDeniedError"));
            }

            Debug.LogErrorFormat("Error: PersistenceExample failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
            enabled = false;
            return;
        }

        pcfsStarted = true;
        if (MLPersistentCoordinateFrames.IsLocalized)
        {
            // Success of PCF systems. Handle startup
            PerformStartup();
        }
        else
        {
            // Wait for initialization callback to check for PCF status
            MLPersistentCoordinateFrames.OnLocalized += HandleInitialized;
        }
    }
Пример #5
0
        /// <summary>
        /// Validates parameters, initializes renderers, and listens to events.
        /// </summary>
        void Start()
        {
            if (_destroyedContentEffect == null)
            {
                Debug.LogError("Error: PersistentBall._destroyedContentEffect is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_nameText == null)
            {
                Debug.LogError("Error: PersistentBall._nameText is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_highlightEffect == null)
            {
                Debug.LogError("Error: PersistentBall._highlightEffect is not set, disabling script.");
                enabled = false;
                return;
            }
            _highlightEffect.SetActive(false);

            if (_lineToPCF == null)
            {
                Debug.LogError("Error: PersistentBall._lineToPCF is not set, disabling script.");
                enabled = false;
                return;
            }

            _lineToPCF.positionCount = 2;
            _lineToPCF.enabled       = false;

            _renderers = GetComponentsInChildren <Renderer>();
            _collider  = GetComponent <Collider>();

            ContentTap contentTap = GetComponent <ContentTap>();

            contentTap.OnContentTap += DestroyContent;

            _nameText.transform.position = transform.position + new Vector3(0, 0.25f, 0);
            _nameText.text = "Object ID:" + gameObject.GetInstanceID();

           #if PLATFORM_LUMIN
            MLResult result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: PersistentBall failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif
        }
        /// <summary>
        /// Responds to privilege requester result.
        /// </summary>
        /// <param name="result">MLResult of the privilege request</param>
        void HandlePrivilegesDone(MLResult result)
        {
            _privilegeRequester.OnPrivilegesDone -= HandlePrivilegesDone;
            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                Debug.LogErrorFormat("Error: PersistenceExample failed to get requested privileges, disabling script. Reason: {0}", result);
                _statusText.text = "<color=red>Failed to acquire necessary privileges</color>";
                enabled          = false;
                return;
            }
            _statusText.text = "Status: Starting up Systems";

            result = MLPersistentStore.Start();
            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                Debug.LogErrorFormat("Error: PersistenceExample failed starting MLPersistentStore, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                MLPersistentStore.Stop();
                Debug.LogErrorFormat("Error: PersistenceExample failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            if (MLPersistentCoordinateFrames.IsReady)
            {
                PerformStartup();
            }
            else
            {
                MLPersistentCoordinateFrames.OnInitialized += HandleInitialized;
            }
        }
        /// <summary>
        /// Starts tracking the landscape and generating tracked PCF GameObjets (Uses MLPersistentCoordinateFrames).
        /// </summary>
        public static void Start(Action onInitializedCallback = null)
        {
            // check if it's already ready or in starting process
            if (IsReady || starting)
            {
                // check what to do with the callback depending on ready or starting status
                if (onInitializedCallback != null)
                {
                    if (IsReady)
                    {
                        onInitializedCallback();
                    }
                    else
                    {
                        OnInitialized += onInitializedCallback;
                    }
                }

                return;
            }

            // initialize MLPersistentCoordinateFrames
            Debug.Log("======== MLULandscape: Initializing landscape... ========");
            if (onInitializedCallback != null)
            {
                OnInitialized += onInitializedCallback;
            }
            MLResult result = MLPersistentCoordinateFrames.Start();

            // check if MLPersistentCoordinateFrames started successfully so we can initialize the landscape
            if (result.IsOk)
            {
                if (MLPersistentCoordinateFrames.IsReady)
                {
                    OnAPIInitialized(result);
                }
                else
                {
                    MLPersistentCoordinateFrames.OnInitialized += OnAPIInitialized;
                    starting = subscribed = true;
                }
            }
            else
            {
                Debug.LogError("MLULandscape error: couldn't start MLPersistentCoordinateFrames!");
                if (OnInitialized != null)
                {
                    OnInitialized();
                }
            }
        }
Пример #8
0
    private void Start()
    {
        pv = GetComponent <PhotonView>();
        if (pv.IsMine)
        {
            NetworkUI = PhotonNetwork.Instantiate("UISync", transform.position, transform.rotation);
            Debug.Log("NetworkUISync object is spawned");
        }
        else
        {
            NetworkUI = GameObject.FindObjectOfType <NetworkUISync>().gameObject;
        }
        _findAllPCFs = FindAllPCFs();
        if (_PCFVizPrefab == null)
        {
            Debug.LogError("PCFVisualizer Prefab is not assigned");
            return;
        }

        MLResult result = MLPersistentStore.Start();

        if (!result.IsOk)
        {
            Debug.LogErrorFormat("Error: PCFVisualizer failed starting MLPersistentStore, disabling script. Reason: {0}", result);
            enabled = false;
            return;
        }
        else
        {
            Debug.Log("Persistent store started");
        }

        result = MLPersistentCoordinateFrames.Start();
        if (!result.IsOk)
        {
            Debug.LogErrorFormat("MLPersistentCoordinateFrames failed to start. Reason {0}", result);
            return;
        }
        else
        {
            Debug.Log("MLPersistentCoordinateFrames started");
        }

        MLPCF.OnCreate += OnNewPCFCreated;
        StartCoroutine(DelayedPCFRetreival());
        if (MLInput.IsStarted == false)
        {
            MLInput.Start();
        }
        MLInput.OnControllerButtonDown += HandleControllerButtonDown;
    }
Пример #9
0
        // Start is called before the first frame update
        void Start()
        {
            this.meshRenderer = GetComponent <MeshRenderer>();
            if (this.meshRenderer == null)
            {
                print("Failed to get this.meshRenderer");
                return;
            }

            this.actsAsManipulatable = GetComponent <ActsAsManipulatable>();
            if (this.actsAsManipulatable == null)
            {
                print("Failed to get this.actsAsManipulatable");
                return;
            }

            ActsAsSwipeable actsAsSwipeable = GetComponent <ActsAsSwipeable>();

            if (actsAsSwipeable != null)
            {
                actsAsSwipeable.swipeLeftDelegate  = OnSwipeLeft;
                actsAsSwipeable.swipeRightDelegate = OnSwipeRight;
            }

            if (!MLPersistentCoordinateFrames.IsStarted)
            {
                MLResult resultStart = MLPersistentCoordinateFrames.Start();
                switch (resultStart.Result)
                {
                case MLResult.Code.Ok:
                {
                    commonStart();
                }
                break;

                case MLResult.Code.PrivilegeDenied:
                    throw new System.NotImplementedException();

                case MLResult.Code.InvalidParam:
                    throw new System.NotImplementedException();

                case MLResult.Code.UnspecifiedFailure:
                    throw new System.NotImplementedException();
                }
            }
            else
            {
                commonStart();
            }
        }
Пример #10
0
        //Init:
        private void Awake()
        {
            //refs:
            _mainCamera = Camera.main.transform;

            //offset helper:
            _transformHelper = new GameObject("(TransformHelper)").transform;
            _transformHelper.gameObject.hideFlags = HideFlags.HideInHierarchy;

            //start systems:
            MLPersistentCoordinateFrames.Start();
            StartCoroutine("PCFDiscovery");

            //hooks:
            Transmission.Instance.events.OnPCF.AddListener(HandlePCFReceived);
            Transmission.Instance.events.OnSpatialAlignment.AddListener(HandleSpatialAlignmentNotification);
        }
Пример #11
0
        /// <summary>
        /// Starts up MLPersistentCoordinateFrames and registers to events.
        /// Defaults to visualizing pcfs (will contiously find and queue PCFs for updates).
        /// </summary>
        void Start()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: PCFVisualizer failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            MLPersistentCoordinateFrames.PCF.OnStatusChange += HandlePCFStatusChange;
            MLPersistentCoordinateFrames.OnLocalized        += HandleOnLocalized;

            IsVisualizing = true;
            #endif
        }
Пример #12
0
        /// <summary>
        /// Validates variables, initializes systems, and prepares to show PCFs
        /// </summary>
        void Start()
        {
            if (_prefab == null)
            {
                Debug.LogError("Error: PCFVisualizer._representativePrefab not set, disabling script.");
                enabled = false;
                return;
            }

            if (_countText == null)
            {
                Debug.LogError("Error: PCFVisualizer._countText not set, disabling script.");
                enabled = false;
                return;
            }

            MLResult result = MLPersistentStore.Start();

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

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

            if (MLPersistentCoordinateFrames.IsReady)
            {
                TryShowingAllPCFs(GetPCFList());
            }
            else
            {
                MLPersistentCoordinateFrames.OnReady += HandleReady;
            }
        }
Пример #13
0
        /// <summary>
        /// Starts APIs, registers to MLInput events, and restores content.
        /// </summary>
        void Start()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: PCFExample failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            PCFVisualizer.OnFindAllPCFs += HandleOnFindAllPCFs;
            MLPersistentCoordinateFrames.OnLocalized += HandleOnLocalized;

            MLInput.OnControllerButtonDown              += HandleControllerButtonDown;
            MLInput.OnControllerTouchpadGestureStart    += HandleTouchpadGestureStart;
            MLInput.OnControllerTouchpadGestureContinue += HandleTouchpadGestureContinue;
            MLInput.OnControllerTouchpadGestureEnd      += HandleTouchpadGestureEnd;
            #endif
        }
Пример #14
0
        #pragma warning restore 414


        /// <summary>
        /// Starts the MLPersistentCoordinateFrames api and initializes bindings.
        /// </summary>
        void Start()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: PCFVisual failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            MLPersistentCoordinateFrames.FindClosestPCF(transform.position, out MLPersistentCoordinateFrames.PCF pcf);

            _visualTransformBinding = new TransformBinding(isPersistent: false);
            _visualTransformBinding.Bind(pcf, transform);

            _visualTextBinding = new TextMeshBinding();
            _visualTextBinding.Bind(pcf, _statusText);
            #endif
        }
Пример #15
0
        /// <summary>
        /// Attempts to start the MLPersistentStore and MLPersistentCoordinateFrames APIs
        /// </summary>
        void StartAPIs()
        {
            _statusText.text = "Status: Starting up Systems";

            MLResult result = MLPersistentStore.Start();

            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                Debug.LogErrorFormat("Error: PersistenceExample failed starting MLPersistentStore, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            result = MLPersistentCoordinateFrames.Start();
            if (!result.IsOk)
            {
                if (result.Code == MLResultCode.PrivilegeDenied)
                {
                    Instantiate(Resources.Load("PrivilegeDeniedError"));
                }

                MLPersistentStore.Stop();
                Debug.LogErrorFormat("Error: PersistenceExample failed starting MLPersistentCoordinateFrames, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            if (MLPersistentCoordinateFrames.IsReady)
            {
                PerformStartup();
            }
            else
            {
                MLPersistentCoordinateFrames.OnInitialized += HandleInitialized;
            }
        }
Пример #16
0
        /// <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);
        }
        /// <summary>
        /// Validates variables, initializes systems, and prepares to show PCFs
        /// </summary>
        void Start()
        {
            if (_prefab == null)
            {
                Debug.LogError("Error: PCFVisualizer._representativePrefab is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_goodPCFCountText == null)
            {
                Debug.LogError("Error: PCFVisualizer._goodPCFCountText is not set, disabling script.");
                enabled = false;
                return;
            }
            _goodPCFCountText.text = "PCFs Loaded: 0";
            _goodPCFCountText.gameObject.SetActive(false);

            MLResult result = MLPersistentStore.Start();

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

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

            MLPCF.OnCreate += HandleCreate;
            _findAllPCFs    = FindAllPCFs();
        }
Пример #18
0
        //Init:
        private IEnumerator Start()
        {
            HideGUI();

            //refs:
            _camera = Camera.main.transform;

            //sets:
            _cachedPrimaryWallGUIScale = selectPrimaryWallGUI.transform.localScale;

            //features:
            MLPersistentCoordinateFrames.Start();
            MLPlanes.Start();
            MLInput.Start();

            //wait for service startup:
            Debug.Log("Waiting for PersistentCoordinateFrames service to localize...");
            while (!MLPersistentCoordinateFrames.IsLocalized)
            {
                yield return(null);
            }
            Debug.Log("PersistentCoordinateFrames service localized!");

            //hooks:
            MLPersistentCoordinateFrames.OnLocalized        += HandleOnLocalized;
            MLPersistentCoordinateFrames.PCF.OnStatusChange += HandlePCFChanged;

            //requirements:
            _surfaceDetails = FindObjectOfType <SurfaceDetails>();
            if (_surfaceDetails == null)
            {
                _surfaceDetails = gameObject.AddComponent <SurfaceDetails>();
            }

            if (runAtStart)
            {
                Create();
            }
        }
Пример #19
0
        /// <summary>
        /// Responds to privilege requester result.
        /// </summary>
        /// <param name="result"/>
        void HandlePrivilegesDone(MLResult result)
        {
            _privilegeRequester.OnPrivilegesDone -= HandlePrivilegesDone;
            if (!result.IsOk)
            {
                string errorMsg = string.Format("Error: PersistenceExample failed to get requested privileges, disabling script. Reason: {0}", result);
                Debug.LogErrorFormat(errorMsg);
                SetProgress(errorMsg);
                enabled = false;
                return;
            }

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

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

            if (MLPersistentCoordinateFrames.IsReady)
            {
                HandleReady();
            }
            else
            {
                MLPersistentCoordinateFrames.OnReady += HandleReady;
            }
        }
Пример #20
0
        /// <summary>
        /// Responds to privilege requester result.
        /// </summary>
        /// <param name="result"/>
        void HandlePrivilegesDone(MLResult result)
        {
            _privilegeRequester.OnPrivilegesDone -= HandlePrivilegesDone;
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: PersistenceExample failed to get requested privileges, disabling script. Reason: {0}", result);
                _statusText.text = "<color=red>Failed to acquire necessary privileges</color>";
                enabled          = false;
                return;
            }
            _statusText.text = "Status: Starting up Systems";

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

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

            if (MLPersistentCoordinateFrames.IsReady)
            {
                HandleReady();
            }
            else
            {
                MLPersistentCoordinateFrames.OnReady += HandleReady;
            }
        }
Пример #21
0
    void HandlePrivilegesDone(MLResult result)
    {
        PrivilegeRequester.OnPrivilegesDone -= HandlePrivilegesDone;
        if (!result.IsOk)
        {
            Debug.LogErrorFormat("Error: PersistentCoordinates failed to get requested privileges, " +
                                 "disabling script. Reason: {0}", result);
            enabled = false;
            return;
        }

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

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

        if (MLPersistentCoordinateFrames.IsReady)
        {
            Inititalize();
        }
        else
        {
            MLPersistentCoordinateFrames.OnInitialized += OnPcfInitialized;
        }
    }