Exemplo n.º 1
0
        /// <summary>
        /// Retrieve the launched screen information and update the visual GameObject.
        /// </summary>
        private bool UpdateLaunchedScreen()
        {
            List <MLScreensScreenInfo> info;

            MLResult result = MLScreens.GetScreensInfo(out info);

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ScreensExample MLScreens.GetScreensInfo failed. Reason {0}.", result);
                return(false);
            }

            if (info.Count == 0)
            {
                _noScreensError.enabled = true;
                Debug.LogWarning("Warning: ScreensExample no screen information was located.");
                return(false);
            }

            // Obtain a list of the available screens and make sure a valid screen is returned.
            MLScreensScreenInfo[] screenInfo = info.Where(x => x.Id == (ulong)MLScreens.GetLauncherScreenId()).ToArray();
            if (screenInfo.Length > 0)
            {
                if (_launchedScreen == null)
                {
                    // Create the initial launched screen GameObject.
                    _launchedScreen = Instantiate(_screenOriginal, screenInfo[0].Position, screenInfo[0].Rotation, transform);
                    _launchedScreen.transform.localScale = Vector3.Scale(screenInfo[0].Dimensions, screenInfo[0].Scale);

                    _launchedScreenInfo = screenInfo[0];

                    _mediaPlayer         = _launchedScreen.GetComponentInChildren <MLMediaPlayer>();
                    _elapsedTime         = _launchedScreen.GetComponentInChildren <TextMesh>();
                    _placementComponenet = _launchedScreen.GetComponentInChildren <PlaceFromCamera>(true);
                }
                else
                {
                    // Assign the active screen info as the launched screen.
                    _launchedScreenInfo = screenInfo[0];

                    // Update the existing screen with the new launched values.
                    _launchedScreen.transform.position   = screenInfo[0].Position;
                    _launchedScreen.transform.rotation   = screenInfo[0].Rotation;
                    _launchedScreen.transform.localScale = Vector3.Scale(screenInfo[0].Dimensions, screenInfo[0].Scale);
                }
            }
            else
            {
                Debug.LogError("Error: ScreensExample was unable to located the launched screen information.");
                enabled = false;

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private void Awake()
        {
            // Canvas Initialization
            _placeFromCamera = GetComponent <PlaceFromCamera>();

            _canvasDistance           = _minDistance;
            _placeFromCamera.Distance = _canvasDistance;

            if (_useLocalization)
            {
                // Title
                _title.text = LocalizeManager.GetString(_title.text);

                // Tabs
                Text overviewTabText = _overviewTab.GetComponentInChildren <Text>(true);
                if (overviewTabText != null)
                {
                    overviewTabText.text = LocalizeManager.GetString(overviewTabText.text);
                }

                Text controlsTabText = _controlsTab.GetComponentInChildren <Text>(true);
                if (controlsTabText != null)
                {
                    controlsTabText.text = LocalizeManager.GetString(controlsTabText.text);
                }

                Text _issueTabText = _issuesTab.GetComponentInChildren <Text>(true);
                if (_issueTabText != null)
                {
                    _issueTabText.text = LocalizeManager.GetString(_issueTabText.text);
                }

                Text _statusTabText = _statusTab.GetComponentInChildren <Text>(true);
                if (_statusTabText != null)
                {
                    _statusTabText.text = LocalizeManager.GetString(_statusTabText.text);
                }

                // Descriptions - Load From File
                _overviewText.text = LocalizeManager.GetString(_overviewText.text);
                _controlsText.text = LocalizeManager.GetString(_controlsText.text);
                _statusText.text   = LocalizeManager.GetString(_statusText.text);
            }

            Application.logMessageReceived += HandleOnLogMessageReceived;

            // Open the these two tabs by default.
            _overviewTab.Pressed();
            _statusTab.Pressed();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets up component dependencies.
        /// </summary>
        void Start()
        {
            if (!MLInput.Start())
            {
                Debug.LogError("Error ControllerCalibration starting MLInput, disabling script.");
                enabled = false;
                return;
            }
            _controller = MLInput.GetController(MLInput.Hand.Left);
            MLInput.OnControllerButtonUp += OnControllerButtonUp;

            _cameraPlacement = GetComponent <PlaceFromCamera>();

            #if !UNITY_EDITOR // Removing calibration step from ML Remote Host builds.
            ResetTransform();
            #else
            _isCalibrated = true;
            #endif
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets up component dependencies.
        /// </summary>
        void Awake()
        {
            if (!MLInput.Start())
            {
                Debug.LogError("Error ControllerCalibration starting MLInput, disabling script.");
                enabled = false;
                return;
            }
            _controller = MLInput.GetController(MLInput.Hand.Left);

            _cameraPlacement = GetComponent <PlaceFromCamera>();

#if UNITY_EDITOR
            // Disable instruction for calibratiion on Simulator.
            if (_calibrationText != null)
            {
                _calibrationText.SetActive(false);
            }
#endif
        }