Пример #1
0
        /// <summary>
        /// Tries to restore the binding or find closest PCF. Note various errors
        /// can be shown during this step based on the state of the low level systems.
        /// </summary>
        void Start()
        {
            SetChildrenActive(false);
            _lockedTransform = gameObject.transform;

            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;
            }

            MLResult result = MLPrivileges.Start();

            if (result.IsOk)
            {
                RequestPrivilege();
            }
            else
            {
                Debug.LogError("Privilege Error: failed to startup");
                enabled = false;
                return;
            }
        }
        #pragma warning restore 649

        /// <summary>
        /// Starts up MLPrivileges.
        /// </summary>
        public static MLResult Start()
        {
            #if PLATFORM_LUMIN
            _result = MLPrivileges.Start();

            if (!_result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLPrivilegesStarterKit failed starting MLPrivileges. Reason: {0}", _result);
            }
            #endif

            return(_result);
        }
        /// <summary>
        /// Sets up the various Persistent systems and starts the object restoration
        /// </summary>
        void Start()
        {
            MLResult result = MLPrivileges.Start();

            if (result.IsOk)
            {
                RequestPrivilege();
            }
            else
            {
                Debug.LogError("Privilege Error: failed to startup");
                enabled = false;
                return;
            }
        }
        /// <summary>
        /// Start Privilege API.
        /// </summary>
        void OnEnable()
        {
            MLResult result = MLPrivileges.Start();

            if (result.IsOk)
            {
                _currentPrivilegeState = PrivilegeState.Started;
            }
            else
            {
                Debug.LogError("Privilege Error: failed to startup");
                enabled = false;
                return;
            }
        }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        // TODO turn back on for osc drawing
        //osc.SetAddressHandler("/date", receiveDraw);

        osc.SetAddressHandler("/rightR", ringSpinR);
        osc.SetAddressHandler("/leftR", ringSpinL);

        osc.SetAddressHandler("/glove", receiveGlove);

        osc.SetAddressHandler("/rod", rodMove);
        MLPrivileges.Start();

        ring.maxAngularVelocity = .4f;
    }
Пример #6
0
    /// <summary>
    /// Start the Privileges API and set the Privilege State
    /// </summary>
    void Start()
    {
        MLResult result = MLPrivileges.Start();

        if (result.IsOk)
        {
            _privilegesToRequest.AddRange(Array.ConvertAll(_privileges,
                                                           tempPrivilege => (MLPrivilegeId)tempPrivilege));
            _state = PrivilegeState.Started;
        }
        else
        {
            Debug.LogErrorFormat(
                "Error: PrivilegeRequester failed starting MLPrivileges, disabling script. Reason: {0}", result);
            _state = PrivilegeState.StartFailed;
            OnPrivilegesDone(result);
            enabled = false;
        }
    }
Пример #7
0
        public static async UniTask RequestPrivilege(MLPrivilegeId privilege)
        {
            // Don't do privilege if app is running in neither ML device nor ZI mode
            if (!XRDevice.isPresent)
            {
                return;
            }

            MLPrivileges.Start().ThrowIfFail();

            MLResult?result = null;

            MLPrivileges.RequestPrivilegeAsync(privilege, (r, _) =>
            {
                result = r;
            }).ThrowIfFail();

            await UniTask.WaitUntil(() => result.HasValue);

            result?.ThrowIfFail();
        }
Пример #8
0
        /// <summary>
        /// Assure that if the 'WorldReconstruction' privilege is missing, then it is logged for all users
        /// </summary>
        private IEnumerator LogWorldReconstructionMissingPrivilege()
        {
            yield return(new WaitUntil(() => MagicLeapDevice.IsReady()));

            MLResult result = MLPrivileges.Start();

            if (result.IsOk)
            {
                result = MLPrivileges.CheckPrivilege(MLPrivilegeId.WorldReconstruction);
                if (result.Code != MLResultCode.PrivilegeGranted)
                {
                    Debug.LogErrorFormat("Error: Unable to create Mesh Subsystem due to missing 'WorldReconstruction' privilege. Please add to manifest. Disabling script.");
                    enabled = false;
                }
                MLPrivileges.Stop();
            }

            else
            {
                Debug.LogErrorFormat("Error: MeshingExample failed starting MLPrivileges. Reason: {0}", result);
            }

            yield return(null);
        }