Пример #1
0
#pragma warning disable CS1998 // Conditional compile statements are removing await
        async void Start()
#pragma warning restore CS1998
        {
            while (!Permission.HasUserAuthorizedPermission(Permission.FineLocation))
            {
                Permission.RequestUserPermission(Permission.FineLocation);
            }

            if (SelectedSceneNameText == null)
            {
                Debug.Log("Missing text field");
                return;
            }

#if !UNITY_EDITOR && (UNITY_WSA || WINDOWS_UWP)
            // Ensure that the device is running a suported build with the spatialperception capability declared.
            bool accessGranted = false;
            try
            {
                Windows.Perception.Spatial.SpatialPerceptionAccessStatus accessStatus = await Windows.Perception.Spatial.SpatialAnchorExporter.RequestAccessAsync();

                accessGranted = (accessStatus == Windows.Perception.Spatial.SpatialPerceptionAccessStatus.Allowed);
            }
            catch {}

            if (!accessGranted)
            {
                Button[] buttons = GetComponentsInChildren <Button>();
                foreach (Button b in buttons)
                {
                    b.gameObject.SetActive(false);
                }

                SelectedSceneNameText.resizeTextForBestFit = true;
                SelectedSceneNameText.verticalOverflow     = VerticalWrapMode.Overflow;
                SelectedSceneNameText.text = "Access denied to spatial anchor exporter.  Ensure your OS build is up to date and the spatialperception capability is set.";
                return;
            }
#endif

            GetScenes();

            if (SceneBuildIndices.Count == 0)
            {
                SelectedSceneNameText.text = "No scenes";
                Debug.Log("Not enough scenes in the build");
                return;
            }

            SceneIndex = 0;
        }
Пример #2
0
        /// <summary>
        /// Returns a value that indicates if the manager is configured and
        /// able to run.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the manager is configured and able to run.; otherwise <c>false</c>.
        /// </returns>
#pragma warning disable CS1998 // Conditional compile statements are removing await
        protected async virtual Task <bool> IsValidateConfiguration()
#pragma warning restore CS1998
        {
#if !UNITY_EDITOR && (UNITY_WSA || WINDOWS_UWP)
            // Ensure that the device is running a suported build with the spatialperception capability declared.
            bool accessGranted = false;
            try
            {
                Windows.Perception.Spatial.SpatialPerceptionAccessStatus accessStatus = await Windows.Perception.Spatial.SpatialAnchorExporter.RequestAccessAsync();

                accessGranted = (accessStatus == Windows.Perception.Spatial.SpatialPerceptionAccessStatus.Allowed);
            }
            catch { }

            if (!accessGranted)
            {
                return(false);
            }
#endif
            // Check based on auth mode
            switch (authenticationMode)
            {
            case AuthenticationMode.ApiKey:
                if (string.IsNullOrWhiteSpace(spatialAnchorsAccountId) || string.IsNullOrWhiteSpace(spatialAnchorsAccountKey))
                {
                    return(false);
                }
                break;

            case AuthenticationMode.AAD:
                if (string.IsNullOrWhiteSpace(clientId) || string.IsNullOrWhiteSpace(tenantId))
                {
                    return(false);
                }
                break;

            default:
                throw new InvalidOperationException("Unknown auth mode");
            }

#if UNITY_ANDROID || UNITY_IOS
            // Check ARFoundation configuration
            if (arCameraManager == null || !arCameraManager.enabled)
            {
                Debug.LogError("Need an enabled ARCameraManager in the scene");
                return(false);
            }

            if (arSession == null || !arSession.enabled)
            {
                Debug.LogError("Need an enabled ARSession in the scene");
                return(false);
            }

            if (arReferencePointManager == null || !arReferencePointManager.enabled)
            {
                Debug.LogError("Need an enabled ARReferencePointManager in the scene");
                return(false);
            }
#endif
            // All checks passed
            return(true);
        }
Пример #3
0
#pragma warning disable CS1998 // Conditional compile statements are removing await
        async void Start()
#pragma warning restore CS1998
        {
            GameObject createFlowBtn = GameObject.Find("CreateFlowButton");

            createFlowBtn.transform.localScale = new Vector3(0, 0, 0);

            GameObject anchorNbrBox = GameObject.Find("AnchorNumberBox");

            anchorNbrBox.transform.localScale = new Vector3(0, 0, 0);

            GameObject mainMenuText = GameObject.Find("CreateAnchorMenuText");

            mainMenuText.transform.localScale = new Vector3(0, 0, 0);

            GameObject exitBtn = GameObject.Find("ExitBtn");

            exitBtn.transform.localScale = new Vector3(0, 0, 0);

            GameObject submitAnchorNameBtn = GameObject.Find("SubmitAnchorNameBtn");

            submitAnchorNameBtn.transform.localScale = new Vector3(0, 0, 0);

            //createAnchorUI.GetComponent<MeshRenderer>().enabled = false;

            /*
             * if (SelectedSceneNameText == null)
             * {
             *  Debug.Log("Missing text field");
             *  return;
             * }
             */
            //        Debug.Log("Setting text field to NavigationListAndNavExecution");
            //       SelectedSceneNameText.text = "NavigationListAndNavExecution";



#if !UNITY_EDITOR && (UNITY_WSA || WINDOWS_UWP)
            // Ensure that the device is running a suported build with the spatialperception capability declared.
            bool accessGranted = false;
            try
            {
                Windows.Perception.Spatial.SpatialPerceptionAccessStatus accessStatus = await Windows.Perception.Spatial.SpatialAnchorExporter.RequestAccessAsync();

                accessGranted = (accessStatus == Windows.Perception.Spatial.SpatialPerceptionAccessStatus.Allowed);
            }
            catch {}

            if (!accessGranted)
            {
                Button[] buttons = GetComponentsInChildren <Button>();
                foreach (Button b in buttons)
                {
                    b.gameObject.SetActive(false);
                }

                SelectedSceneNameText.resizeTextForBestFit = true;
                SelectedSceneNameText.verticalOverflow     = VerticalWrapMode.Overflow;
                SelectedSceneNameText.text = "Access denied to spatial anchor exporter.  Ensure your OS build is up to date and the spatialperception capability is set.";
                return;
            }
#endif

            GetScenes();

            if (SceneBuildIndices.Count == 0)
            {
                SelectedSceneNameText.text = "No scenes";
                Debug.Log("Not enough scenes in the build");
                return;
            }

            SceneIndex = 0;
        }
Пример #4
0
        /// <summary>
        /// Returns a value that indicates if the manager is configured and
        /// able to run.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the manager is configured and able to run.; otherwise <c>false</c>.
        /// </returns>
#pragma warning disable CS1998 // Conditional compile statements are removing await
        protected async virtual Task <bool> IsValidateConfiguration()
#pragma warning restore CS1998
        {
#if !UNITY_EDITOR && (UNITY_WSA || WINDOWS_UWP)
            // Ensure that the device is running a supported build with the spatialperception capability declared.
            bool accessGranted = false;
            try
            {
                Windows.Perception.Spatial.SpatialPerceptionAccessStatus accessStatus = await Windows.Perception.Spatial.SpatialAnchorExporter.RequestAccessAsync();

                accessGranted = (accessStatus == Windows.Perception.Spatial.SpatialPerceptionAccessStatus.Allowed);
            }
            catch { }

            if (!accessGranted)
            {
                return(false);
            }
#endif

            // An AccountDomain must be specified for the configuration to be valid.
            if (string.IsNullOrWhiteSpace(spatialAnchorsAccountDomain))
            {
                return(false);
            }

            // Check based on auth mode
            switch (authenticationMode)
            {
            case AuthenticationMode.ApiKey:
                if (string.IsNullOrWhiteSpace(spatialAnchorsAccountId) || string.IsNullOrWhiteSpace(spatialAnchorsAccountKey))
                {
                    return(false);
                }
                break;

            case AuthenticationMode.AAD:
                break;

            default:
                throw new InvalidOperationException("Unknown auth mode");
            }

#if UNITY_ANDROID || UNITY_IOS
            // Check AR Foundation configuration
            // On Android the ARCameraManager can take a few seconds to get going.
            int retries = 0;
            while (retries++ < 60)
            {
                if (arCameraManager != null && arCameraManager.enabled)
                {
                    break;
                }
                await Task.Delay(100);
            }

            if (arCameraManager == null || !arCameraManager.enabled)
            {
                Debug.LogError("Need an enabled ARCameraManager in the scene");
                return(false);
            }

            if (arSession == null || !arSession.enabled)
            {
                Debug.LogError("Need an enabled ARSession in the scene");
                return(false);
            }

            if (arAnchorManager == null || !arAnchorManager.enabled)
            {
                Debug.LogError("Need an enabled ARAnchorManager in the scene");
                return(false);
            }
#endif
            // All checks passed
            return(true);
        }