/// <summary>
        /// Start the MLLocation API.
        /// </summary>
        public static MLResult Start()
        {
            MLResult result = MLPrivilegesStarterKit.Start();

            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLLocationStarterKit failed starting MLPrivilegesStarterKit, Reason {0} ", result);
                return(result);
            }
            result = MLPrivilegesStarterKit.RequestPrivileges(MLPrivileges.Id.FineLocation, MLPrivileges.Id.CoarseLocation);

            if (result.Result != MLResult.Code.PrivilegeGranted)
            {
                Debug.LogErrorFormat("Error: MLLocationStarterKit failed requesting privileges, reason {0} ", result);
                return(result);
            }

            MLPrivilegesStarterKit.Stop();

            result = MLLocation.Start();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLLocationStarterKit failed to start, Reason: {0}", result);
            }
            #endif

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the MLLocation API and polls data if needed.
        /// </summary>
        private void StartupAPI()
        {
            MLLocation.Start();

            // Only want to place the pin once
            if (!_placedPin)
            {
                GetLocation();
            }
        }
    void OnApplicationPause(bool pauseStatus)
    {
        if (!pauseStatus)
        {
            if (!MLLocation.IsStarted)
            {
                MLLocation.Start();
            }

            MLCamera.Start();
            MLCamera.Connect();
            MLCamera.StartPreview();
        }
        else
        {
            OnDisable();
        }
    }
    void OnEnable()
    {
        Logger.D(TAG, "Called OnEnable()...");

        // Start MagicLeap's Location service:
        if (!MLLocation.IsStarted)
        {
            MLLocation.Start();
        }

        // Needs a render Texture.
        Logger.D(TAG, "Calling Start to camera...");
        MLCamera.Start();
        Logger.D(TAG, "Calling Connect()...");
        MLCamera.Connect();

        Logger.D(TAG, "Calling StartPreview()...");
        MLCamera.StartPreview();

        Logger.D(TAG, "Setting texture sizes app side...");

        // Preview has fixed capture height and width. May need a prepare capture to do parameters not in preview.
        W = MLCamera.PreviewTextureWidth;
        H = MLCamera.PreviewTextureHeight;

        // Image width and height to send to face detection server
        ImageWidth  = 1440;
        ImageHeight = 1080;


        // Allocate space for render buffers:
        tmp = RenderTexture.GetTemporary(
            W,
            H,
            0,
            RenderTextureFormat.ARGB32,
            RenderTextureReadWrite.Linear);
        nt = new Texture2D(ImageWidth, ImageHeight, TextureFormat.ARGB32, false);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Starts the MLLocation API and polls data if needed.
 /// </summary>
 private void StartupAPI()
 {
     MLLocation.Start();
     GetLocation();
     StartCoroutine(GetFineLocationLoop());
 }