void Awake() { // Before enabling the microphone, the scene must wait until the privileges have been granted. _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandleOnPrivilegesDone; }
void Awake() { if (instance == null) { instance = this; } else { Debug.LogError(instance.name + " exists: two spatiate alignment instances. Destroying this (" + name + ")"); Destroy(gameObject); return; } #if !XR_NON_MAGIC_LEAP _privilegeRequester = GetComponent <PrivilegeRequester>(); if (_privilegeRequester == null) { Debug.LogError("Missing PrivilegeRequester component"); enabled = false; return; } // Could have also been set via the editor. _privilegeRequester.Privileges = new[] { MLRuntimeRequestPrivilegeId.PwFoundObjRead }; _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; #endif }
// Start is called before the first frame update void Start() { _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the MLImageTrackerBehavior GameObjects, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
void Awake() { _privilegeRequester = GetComponent <PrivilegeRequester>(); if (_privilegeRequester == null) { Debug.LogError("Missing PrivilegeRequester component"); enabled = false; return; } // Could have also been set via the editor. _privilegeRequester.Privileges = new[] { MLRuntimeRequestPrivilegeId.PwFoundObjRead }; _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; _filePath = Path.Combine(Application.persistentDataPath, _fileName); Debug.Log("File Path: " + _filePath); MLResult result = MLInput.Start(); if (!result.IsOk) { SetProgress(TEXT_FAILED_TO_START_INPUT); } else { MLInput.OnControllerButtonDown += HandleButtonDown; } }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { enabled = false; if (_controllerConnectionHandler == null) { Debug.LogError("Error: VideoCamptureExample._controllerConnectionHandler is not set, disabling script."); return; } if (_intrinsicValuesText == null) { Debug.LogError("Error: VideoCamptureExample._intrinsicValuesText is not set, disabling script."); return; } if (_framePoseTransform == null) { Debug.LogError("Error: VideoCamptureExample._framePoseTransform is not set, disabling script."); return; } enabled = true; _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the Camera, the scene must wait until the privileges have been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
private void Awake() { // Request privileges Debug.Log("Requesting Privileges"); _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; StartCoroutine(setPosition()); }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); //_privilegeRequester = GameObject.FindGameObjectWithTag("ActivitySequenceManager").GetComponent<PrivilegeRequester>(); // Before enabling the MLImageTrackerBehavior GameObjects, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
/// <summary> /// Validate properties. Attach event listener to when privileges are granted /// on Awake because the privilege requester requests on Start. /// </summary> void Awake() { if (_content == null || _content.GetComponent <MLPersistentBehavior>() == null) { Debug.LogError("Error: PersistenceExample._content is not set or is missing MLPersistentBehavior behavior, disabling script."); enabled = false; return; } if (_destroyedContentEffect == null) { Debug.LogError("Error: PersistenceExample._destroyedContentEffect is not set, disabling script."); enabled = false; return; } if (_controller == null) { Debug.LogError("Error: PersistenceExample._controller is not set, disabling script."); enabled = false; return; } if (_statusText == null) { Debug.LogError("Error: PersistenceExample._statusText is not set, disabling script."); enabled = false; return; } if (_countCreatedText == null) { Debug.LogError("Error: PersistenceExample._countCreatedText is not set, disabling script."); enabled = false; return; } _countCreatedTextFormat = _countCreatedText.text; _countCreatedText.text = string.Format(_countCreatedTextFormat, _countCreatedGood, _countCreatedBad); if (_countRestoredText == null) { Debug.LogError("Error: PersistenceExample._countRestoredText is not set, disabling script."); enabled = false; return; } _countRestoredTextFormat = _countRestoredText.text; _countRestoredText.text = string.Format(_countRestoredTextFormat, _countRestoredGood, _countRestoredBad); // _privilegeRequester is expected to request for PwFoundObjRead privilege _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; _statusText.text = "Status: Requesting Privileges"; MLInput.OnControllerButtonDown += HandleControllerButtonDown; }
void Awake() { if (_inputAudioSource == null) { Debug.LogError("Error: AudioCaptureExample._inputAudioSource is not set, disabling script."); enabled = false; return; } if (_playbackAudioSource == null) { Debug.LogError("Error: AudioCaptureExample._playbackAudioSource is not set, disabling script."); enabled = false; return; } if (_parrotTransform == null) { Debug.LogError("Error: AudioCaptureExample._parrotTransform is not set, disabling script."); enabled = false; return; } if (_parrotAnimator == null) { Debug.LogError("Error: AudioCaptureExample._parrotAnimator is not set, disabling script."); enabled = false; return; } if (_statusLabel == null) { Debug.LogError("Error: AudioCaptureExample._statusLabel is not set, disabling script."); enabled = false; return; } if (_controllerConnectionHandler == null) { Debug.LogError("Error: AudioCaptureExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } // Before enabling the microphone, the scene must wait until the privileges have been granted. _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandleOnPrivilegesDone; MLInput.OnControllerButtonDown += HandleOnButtonDown; }
private void Awake() { // Request privileges (primarily LAN permission) MLog("Requesting Privileges"); privilegeRequester = GetComponent <PrivilegeRequester>(); privilegeRequester.OnPrivilegesDone += handlePrivilegesDone; // Initialise raw image display rawImageTexture = new Texture2D(960, 540, TextureFormat.RGB24, false); rawImage.texture = rawImageTexture; StartCoroutine(displayJpgs()); StartCoroutine(monitorConnection()); }
private void Awake() { if (_statusText == null) { Debug.LogError("Error: LocationExample._statusText is not set, disabling script."); enabled = false; return; } if (_coarseLocationText == null) { Debug.LogError("Error: LocationExample._coarseLocationText is not set, disabling script."); enabled = false; return; } if (_fineLocationText == null) { Debug.LogError("Error: LocationExample._fineLocationText is not set, disabling script."); enabled = false; return; } if (_pin == null) { Debug.LogError("Error: LocationExample._pin is not set, disabling script."); enabled = false; return; } if (_globe == null) { Debug.LogError("Error: LocationExample._globe is not set, disabling script."); enabled = false; return; } _mainCameraTransform = Camera.main.transform; _globe.SetActive(false); _pin.gameObject.SetActive(false); _privilegeRequester = GetComponent <PrivilegeRequester>(); if (_privilegeRequester) { // Register event listener. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; } }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { currentIndex = 0; UpdateVisualizers(); // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the MLImageTrackerBehavior GameObjects, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; /*debugCube = GameObject.CreatePrimitive(PrimitiveType.Cube); * debugCube2 = GameObject.CreatePrimitive(PrimitiveType.Cube); * debugCube.transform.localScale = new Vector3(0.025f, 0.025f, 0.025f); * debugCube2.transform.localScale = new Vector3(0.025f, 0.025f, 0.025f); */ meshParent = FindObjectOfType <MLSpatialMapper>().meshParent; anchoredPositions = new Vector3[TrackerBehaviours.Length]; anchoredLookAts = new Vector3[TrackerBehaviours.Length]; totalPositions = new List <Vector3> [TrackerBehaviours.Length]; totalLookAts = new List <Vector3> [TrackerBehaviours.Length]; calibrating = new bool[TrackerBehaviours.Length]; for (var i = 0; i < calibrating.Length; i++) { startCalibrating(i); } //finishCalibrating(0); //finishCalibrating(1); /*Invoke("fin", 1); * Invoke("fin", 2); * Invoke("fin", 3); * Invoke("fin", 4); * Invoke("fin", 5); * Invoke("fin", 6); * Invoke("fin", 7); * Invoke("fin", 8); * Invoke("fin", 9); * Invoke("fin", 10); * Invoke("fin", 11); * Invoke("fin", 12); * Invoke("fin", 13); * Invoke("fin", 14);*/ currentFocus = -1; mutex = false; }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { _privilegeRequester = GetComponent <PrivilegeRequester>(); if (_privilegeRequester == null) { Debug.LogError("Missing PrivilegeRequester component"); enabled = false; return; } // Could have also been set via the editor. _privilegeRequester.Privileges = new[] { MLRuntimeRequestPrivilegeId.CameraCapture, MLRuntimeRequestPrivilegeId.AudioCaptureMic }; _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
void RequestPrivs() { _privilegeRequester = GetComponent <PrivilegeRequester>(); if (_privilegeRequester == null) { // Handle if the Privilege Requester is missing from the scene } // Could have also been set via the editor. _privilegeRequester.Privileges = new[] { MLRuntimeRequestPrivilegeId.LocalAreaNetwork, MLRuntimeRequestPrivilegeId.CoarseLocation }; _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
void Awake() { connectionHandler = GetComponent <ControllerConnectionHandler>(); if (connectionHandler == null) { Debug.Log("Error "); enabled = false; return; } // camera editor privilegeRequester = GetComponent <PrivilegeRequester>(); debugLog.text = "Setting up Onprivilegesdone binding "; //antes de iniciar los objetos mltracker la escena deberia esperar privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { if (_controllerConnectionHandler == null) { Debug.LogError("Error: ImageTrackingExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the MLImageTrackerBehavior GameObjects, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
public static void SensitivePrivilegeRequired(MLRuntimeRequestPrivilegeId privilege) { PrivilegeRequester privilegeRequester = GameObject.FindObjectOfType <PrivilegeRequester>(); if (privilegeRequester != null) { if (privilegeRequester.Privileges == null) { InspectorInfoBox($"This component requires a sensitive privilige. Include {privilege} in your instance of PrivilegeRequester and make sure the equivalent privilege has been added to your manifest.", MessageType.Error); } else if (Array.IndexOf <MLRuntimeRequestPrivilegeId>(privilegeRequester.Privileges, privilege) == -1) { InspectorInfoBox($"This component requires a sensitive privilige. Include {privilege} in your instance of PrivilegeRequester and make sure the equivalent privilege has been added to your manifest.", MessageType.Error); } } }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { _texture = new Texture2D(1920, 1080); if (_controllerConnectionHandler == null) { Debug.LogError("Error: VideoCamptureExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture and AudioCaptureMic in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the Camera, the scene must wait until the privileges have been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
public static async UniTask WaitAllGranted(this PrivilegeRequester p, bool usingZi) { if (Application.isEditor && !usingZi) { return; } var result = await Observable .FromEvent <MLResult>( h => p.OnPrivilegesDone += h, h => p.OnPrivilegesDone -= h) .First(); if (!result.IsOk) { throw new Exception("Privileges failed"); } }
private void Start() { if (_light == null) { Debug.LogError("Error: LightTrackingExample._light is not set, disabling script."); enabled = false; return; } if (_lightIntensity == null) { Debug.LogError("Error: LightTrackingExample._lightIntensity is not set, disabling script."); enabled = false; return; } if (_animator == null) { Debug.LogError("Error: LightTrackingExample._animator is not set, disabling script."); enabled = false; return; } if (_plantModel == null) { Debug.LogError("Error: LightTrackingExample._plantModel is not set, disabling script."); enabled = false; return; } if (_raycastCursor == null) { Debug.LogError("Error: LightTrackingExample._raycastCursor is not set, disabling script."); enabled = false; return; } _privilegeRequester = GetComponent <PrivilegeRequester>(); // Register Listeners // Before enabling the camera, the scene must wait until the privileges have been granted. _privilegeRequester.OnPrivilegesDone += HandleOnPrivilegesDone; MLInput.OnControllerButtonDown += HandleOnButtonDown; }
/// <summary> /// Using Awake so that Privileges is set before PrivilegeRequester Start. /// </summary> void Awake() { if (_controllerConnectionHandler == null) { Debug.LogError("Error: ImageCaptureExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } MLInput.Start(); // to start receiving input from the controller _controller = MLInput.GetController(MLInput.Hand.Left); // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the Camera, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }
/// <summary> /// Using Awake so that Privileges is set before PrivilegeRequester Start. /// </summary> void Awake() { if (_controllerConnectionHandler == null) { Debug.LogError("Error: ImageCaptureExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the Camera, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; classes_filepath = Utils.getFilePath("dnn/" + classes); input_filepath = Utils.getFilePath("dnn/" + input); config_filepath = Utils.getFilePath("dnn/" + config); model_filepath = Utils.getFilePath("dnn/" + model); }
/// <summary> /// Validate properties. Attach event listener to when privileges are granted /// on Awake because the privilege requester requests on Start. /// </summary> void Awake() { if (_controllerConnectionHandler == null) { Debug.LogError("Error: PersistanceExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } if (_prefab == null || _prefab.GetComponent <MLPersistentPoint>() == null) { Debug.LogError("Error: PersistanceExample._prefab is not set or is missing MLPersistentPoint behavior, disabling script."); enabled = false; return; } if (_progressText == null) { Debug.LogError("Error: PersistanceExample._progressText is not set, disabling script."); enabled = false; return; } if (_persistentPointsStatusText == null) { Debug.LogError("Error: PersistanceExample._persistentPointsStatusText is not set, disabling script."); enabled = false; return; } // _privilegeRequester is expected to request for PwFoundObjRead privilege _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; MLInput.OnControllerButtonDown += HandleButtonDown; }
// Using Awake so that Privileges is set before PrivilegeRequester Start void Awake() { if (_controllerConnectionHandler == null) { Debug.LogError("Error: ImageTrackingExample._controllerConnectionHandler is not set, disabling script."); enabled = false; return; } // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester>(); // Before enabling the MLImageTrackerBehavior GameObjects, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; debugCube = GameObject.CreatePrimitive(PrimitiveType.Cylinder); debugCube.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); trackedObjectPositions = new Vector3[TrackerBehaviours.Length]; for (var i = 0; i < trackedObjectPositions.Length; i++) { trackedObjectPositions[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity); } }
public void Awake() { PrivilegeRequester privilegeRequester = GetComponent <PrivilegeRequester> (); privilegeRequester.enabled = false; }
/// <summary> /// Initializes this instance by coroutine. /// </summary> protected virtual IEnumerator _Initialize() { if (hasInitDone) { ReleaseResources(); if (onDisposed != null) { onDisposed.Invoke(); } } isInitWaiting = true; #if !UNITY_EDITOR // If not listed here, the PrivilegeRequester assumes the request for // the privileges needed, CameraCapture in this case, are in the editor. _privilegeRequester = GetComponent <PrivilegeRequester> (); // Before enabling the Camera, the scene must wait until the privilege has been granted. _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; yield return(null); #else float requestedFPS = this.requestedFPS; // Creates the camera if (!String.IsNullOrEmpty(requestedDeviceName)) { int requestedDeviceIndex = -1; if (Int32.TryParse(requestedDeviceName, out requestedDeviceIndex)) { if (requestedDeviceIndex >= 0 && requestedDeviceIndex < WebCamTexture.devices.Length) { webCamDevice = WebCamTexture.devices [requestedDeviceIndex]; if (avoidAndroidFrontCameraLowLightIssue && webCamDevice.isFrontFacing == true) { requestedFPS = 15f; } if (requestedFPS < 0) { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight); } else { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight, (int)requestedFPS); } } } else { for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; cameraIndex++) { if (WebCamTexture.devices [cameraIndex].name == requestedDeviceName) { webCamDevice = WebCamTexture.devices [cameraIndex]; if (avoidAndroidFrontCameraLowLightIssue && webCamDevice.isFrontFacing == true) { requestedFPS = 15f; } if (requestedFPS < 0) { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight); } else { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight, (int)requestedFPS); } break; } } } if (webCamTexture == null) { Debug.Log("Cannot find camera device " + requestedDeviceName + "."); } } if (webCamTexture == null) { // Checks how many and which cameras are available on the device for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; cameraIndex++) { if (WebCamTexture.devices [cameraIndex].isFrontFacing == requestedIsFrontFacing) { webCamDevice = WebCamTexture.devices [cameraIndex]; if (avoidAndroidFrontCameraLowLightIssue && webCamDevice.isFrontFacing == true) { requestedFPS = 15f; } if (requestedFPS < 0) { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight); } else { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight, (int)requestedFPS); } break; } } } if (webCamTexture == null) { if (WebCamTexture.devices.Length > 0) { webCamDevice = WebCamTexture.devices [0]; if (avoidAndroidFrontCameraLowLightIssue && webCamDevice.isFrontFacing == true) { requestedFPS = 15f; } if (requestedFPS < 0) { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight); } else { webCamTexture = new WebCamTexture(webCamDevice.name, requestedWidth, requestedHeight, (int)requestedFPS); } } else { isInitWaiting = false; if (onErrorOccurred != null) { onErrorOccurred.Invoke(ErrorCode.CAMERA_DEVICE_NOT_EXIST); } yield break; } } // Starts the camera webCamTexture.Play(); int initFrameCount = 0; bool isTimeout = false; while (true) { if (initFrameCount > timeoutFrameCount) { isTimeout = true; break; } // If you want to use webcamTexture.width and webcamTexture.height on iOS, you have to wait until webcamTexture.didUpdateThisFrame == 1, otherwise these two values will be equal to 16. (http://forum.unity3d.com/threads/webcamtexture-and-error-0x0502.123922/) #if UNITY_IOS && !UNITY_EDITOR && (UNITY_4_6_3 || UNITY_4_6_4 || UNITY_5_0_0 || UNITY_5_0_1) else if (webCamTexture.width > 16 && webCamTexture.height > 16) { #else else if (webCamTexture.didUpdateThisFrame) { #if UNITY_IOS && !UNITY_EDITOR && UNITY_5_2 while (webCamTexture.width <= 16) { if (initFrameCount > timeoutFrameCount) { isTimeout = true; break; } else { initFrameCount++; } webCamTexture.GetPixels32(); yield return(new WaitForEndOfFrame()); } if (isTimeout) { break; } #endif #endif Debug.Log("WebCamTextureToMatHelper:: " + "devicename:" + webCamTexture.deviceName + " name:" + webCamTexture.name + " width:" + webCamTexture.width + " height:" + webCamTexture.height + " fps:" + webCamTexture.requestedFPS + " videoRotationAngle:" + webCamTexture.videoRotationAngle + " videoVerticallyMirrored:" + webCamTexture.videoVerticallyMirrored + " isFrongFacing:" + webCamDevice.isFrontFacing); if (colors == null || colors.Length != webCamTexture.width * webCamTexture.height) { colors = new Color32[webCamTexture.width * webCamTexture.height]; } frameMat = new Mat(webCamTexture.height, webCamTexture.width, CvType.CV_8UC4); screenOrientation = Screen.orientation; screenWidth = Screen.width; screenHeight = Screen.height; bool isRotatedFrame = false; #if !UNITY_EDITOR && !(UNITY_STANDALONE || UNITY_WEBGL) if (screenOrientation == ScreenOrientation.Portrait || screenOrientation == ScreenOrientation.PortraitUpsideDown) { if (!rotate90Degree) { isRotatedFrame = true; } } else if (rotate90Degree) { isRotatedFrame = true; } #else if (rotate90Degree) { isRotatedFrame = true; } #endif if (isRotatedFrame) { rotatedFrameMat = new Mat(webCamTexture.width, webCamTexture.height, CvType.CV_8UC4); } isInitWaiting = false; hasInitDone = true; initCoroutine = null; if (onInitialized != null) { onInitialized.Invoke(); } break; } else { initFrameCount++; yield return(null); } } if (isTimeout) { webCamTexture.Stop(); webCamTexture = null; isInitWaiting = false; initCoroutine = null; if (onErrorOccurred != null) { onErrorOccurred.Invoke(ErrorCode.TIMEOUT); } } #endif }
void Awake() { _privilegeRequester = GetComponent <PrivilegeRequester>(); _privilegeRequester.OnPrivilegesDone += HandlePrivilegesDone; }