protected virtual void OnTrackingFound() { if (mTrackableBehaviour) { var rendererComponents = mTrackableBehaviour.GetComponentsInChildren <Renderer>(true); var colliderComponents = mTrackableBehaviour.GetComponentsInChildren <Collider>(true); var canvasComponents = mTrackableBehaviour.GetComponentsInChildren <Canvas>(true); PlayOnStateChange player = mTrackableBehaviour.GetComponentInChildren <PlayOnStateChange>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } if (player != null) { player.Initialize(); player.PlayOnAppear(); } } }
public void PlayInfoClips() { if (trackableObjects.Count < 1) { Debug.Log("No Trackables Found!"); return; } if (currentTrackedPlayAudioTarget == null || currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() == null) { Debug.Log("No PlayAudio script attached to this object, or there is no active trackable target atm!"); return; } breakOutOfQuestions = true; if (playAudio != null) { playAudio.PlayInfoClipOnClick(); if (userSettings != null) { userSettings.FadeBGMusicVolume(playAudio.GetAudioSource().clip.length + 0.5f); } } }
/// <summary> /// Implementation of the ITrackableEventHandler function called when the /// tracking state changes. /// </summary> public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { m_PreviousStatus = previousStatus; m_NewStatus = newStatus; vidPlay = mTrackableBehaviour.GetComponentInChildren <VideoPlayer>(); if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found"); OnTrackingFound(); vidPlay.Play(); } else if (previousStatus == TrackableBehaviour.Status.TRACKED && newStatus == TrackableBehaviour.Status.NO_POSE) { Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost"); OnTrackingLost(); vidPlay.Pause(); } else { // For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND // Vuforia is starting, but tracking has not been lost or found yet // Call OnTrackingLost() to hide the augmentations OnTrackingLost(); } }
protected virtual void OnTrackingFound() { var rendererComponents = GetComponentsInChildren <Renderer>(true); var colliderComponents = GetComponentsInChildren <Collider>(true); var canvasComponents = GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } cameraObject.GetComponent <MainManager>().vid = mTrackableBehaviour.GetComponentInChildren <VideoPlayer>(); cameraObject.GetComponent <MainManager>().DisplayUI(); }
protected virtual void OnTrackingFound() { var rendererComponents = GetComponentsInChildren <Renderer>(true); var colliderComponents = GetComponentsInChildren <Collider>(true); var canvasComponents = GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } vid = mTrackableBehaviour.GetComponentInChildren <VideoPlayer>(); if (vid) { vid.Play(); } }
protected virtual void OnTrackingFound() { var rendererComponents = GetComponentsInChildren <Renderer>(true); var colliderComponents = GetComponentsInChildren <Collider>(true); var canvasComponents = GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } mCameraObject.GetComponent <VideoController>().mVid = mTrackableBehaviour.GetComponentInChildren <VideoPlayer>(); mCameraObject.GetComponent <VideoController>().PlayVideo(); }
protected virtual void OnTrackingFound() { if (mTrackableBehaviour) { var rendererComponents = mTrackableBehaviour.GetComponentsInChildren <Renderer>(true); var colliderComponents = mTrackableBehaviour.GetComponentsInChildren <Collider>(true); var canvasComponents = mTrackableBehaviour.GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } cameraObject.GetComponent <VideoControler>().vid = mTrackableBehaviour.GetComponentInChildren <VideoPlayer>(); cameraObject.GetComponent <VideoControler>().Play; } if (OnTargetFound != null) { OnTargetFound.Invoke(); } }
public void SetColorForCardboard(Color color) { _color = color; if (gameManager != null) { if (gameManager.currentTrackedPlayAudioTarget != null) { currentTrackedAnimal = gameManager.currentTrackedPlayAudioTarget; if (currentTrackedAnimal.GetComponentInChildren <Renderer>() != null) { currentTrackedAnimal.GetComponentInChildren <Renderer>().sharedMaterial.color = _color; } } } }
// to enable new objects public void onNextARObject() { mTrackableBehaviour.GetComponentInChildren <ArtGalleryVideoController>().Pause(); mTrackableBehaviour.GetComponentInChildren <AudioController>().Pause(); selectedARObject++; // reset position of every object except video, audio, and te if (selectedARObject < len_tutorialInstantiedObjects) { if (selectedARObject == 7 || selectedARObject == 8 || selectedARObject == 9) { // do nothing } else { mTrackableBehaviour.gameObject.transform.position = new Vector3(transformations[0, 0], transformations[0, 1], transformations[0, 2]); var tutorialInstantiedObjects = mTrackableBehaviour.gameObject.GetComponentInChildren <Transform>(); foreach (Transform tr in tutorialInstantiedObjects.transform.GetChild(selectedARObject)) { // Debug.Log("yolo"); // Debug.Log(tr.position.x); // Debug.Log(tr.position.y); // Debug.Log(tr.position.z); //Debug.Log("realyolo"); tr.position = new Vector3(transformations[0, 0], transformations[0, 1], transformations[0, 2]); //tr.eulerAngles = new Vector3(transformations[1,0], transformations[1,1], transformations[1,2]); tr.localScale = new Vector3(transformations[2, 0], transformations[2, 1], transformations[2, 2]); // Debug.Log(transformations[0, 0]); // pos.x // Debug.Log(transformations[0, 1]); // pos.y // Debug.Log(transformations[0, 2]); // pos.z } } } TutorialRenderHandler(); }
protected virtual void OnTrackingFound() { if (mTrackableBehaviour) { var rendererComponents = mTrackableBehaviour.GetComponentsInChildren <Renderer>(true); var colliderComponents = mTrackableBehaviour.GetComponentsInChildren <Collider>(true); var canvasComponents = mTrackableBehaviour.GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } if (string.Equals(mTrackableBehaviour.TrackableName, "stone")) { Debug.Log("Interaction Marker Detected"); } else { Debug.Log("Calling Marker Script"); var markerScript = mTrackableBehaviour.GetComponentInChildren <ChartLoadScript>(true); markerScript.Load(mTrackableBehaviour.TrackableName); } } }
void GetCurrentTrackableObjects() { StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); if (activeTrackables.Count() == 0 && !takingScreenshot) { unfocusImage.SetActive(true); backBtn.SetActive(true); infoBtn.SetActive(false); /*infoBtn.SetActive(false); * screenShotBtn.SetActive(false); * cameSwapBtn.SetActive(false); * animateBtn.SetActive(false);*/ //stickerBtn.SetActive(false); //save.SetActive(false); //removeImage.SetActive(false); } else if (activeTrackables.Count() >= 1) { takingScreenshot = true; infoBtn.SetActive(true); } else { takingScreenShot = false; unfocusImage.SetActive(false); //infoBtn.SetActive(true); //backBtn.SetActive(false); /*infoBtn.SetActive(true); * screenShotBtn.SetActive(true); * cameSwapBtn.SetActive(true); * animateBtn.SetActive(true);*/ //stickerBtn.SetActive(true); } noOfActiveTrackables = activeTrackables.Count(); foreach (TrackableBehaviour tb in activeTrackables) { //Debug.Log("Trackable: " + tb.TrackableName); currentTrackedTarget = tb; if (currentTrackedTarget.GetComponentInChildren <TouchControls>()) { currentTrackedTarget.GetComponentInChildren <TouchControls>().objectVisible = true; } foreach (GameObject obj in objects) { GameObject ro = obj.GetComponent <SnappedObject>().refObject; if (ro != null) { if (ro.activeSelf) { ro.SetActive(false); } } } trackableObjects.Add(currentTrackedTarget); currentTrackedTargetName = currentTrackedTarget.TrackableName; } }
void GetCurrentTrackableObjects() { // Get the StateManager StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); noOfActiveTrackables = activeTrackables.Count(); // Iterate through the list of active trackables foreach (TrackableBehaviour tb in activeTrackables) { //Debug.Log("Trackable: " + tb.TrackableName); if (tb.TrackableName != "action-card" && tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { currentTrackedPlayAudioTarget = tb; cardTrackingTimer += Time.deltaTime; if (!playedAnimalNameOnce && cardTrackingTimer >= 1.75f) { if (currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() != null) { playAudio = currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>(); playAudio.PlayAnimalNameClipOnClick(); } playedAnimalNameOnce = true; } } currentTrackedTarget = tb; if (currentTrackedTarget.GetComponentInChildren <TouchControls>()) { currentTrackedTarget.GetComponentInChildren <TouchControls>().objectVisible = true; } if (currentTrackedTarget.TrackableName == "action-card" && noOfActiveTrackables == 1) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(false); } } else { if (!takingScreenshot) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(true); } } } foreach (GameObject obj in objects) { GameObject ro = obj.GetComponent <SnappedObject>().refObject; if (ro != null) { if (ro.activeSelf) { ro.SetActive(false); } } } trackableObjects.Add(currentTrackedTarget); currentTrackedTargetName = currentTrackedTarget.TrackableName; if (!source.isPlaying && !breakOutOfQuestions && currentTrackedTargetName != "action-card" && currentTrackedTargetName != "groundcard") { if (!scannedCurrentTrackable && cardTrackingTimer >= timeBeforeQuestionsPlayRightOrWRong) { if (!answeredCorrectly) { if (Time.time > msTimeBeforePlayingCorrectOrWrong) { if (currentTrackedTargetName == names[randomIndex]) { switch (currentChoosenLanguage) { case "English": source.clip = answers[0]; break; case "Chinese": source.clip = answers[2]; break; default: source.clip = answers[0]; break; } if (userSettings != null) { userSettings.FadeBGMusicVolume(source.clip.length + 0.5f); } source.Play(); answeredCorrectly = true; } else { switch (currentChoosenLanguage) { case "English": source.clip = answers[1]; break; case "Chinese": source.clip = answers[3]; break; default: source.clip = answers[1]; break; } if (userSettings != null) { userSettings.FadeBGMusicVolume(source.clip.length + 0.5f); } source.Play(); } scannedCurrentTrackable = true; } } } } } }
void Update() { if (startColoring) { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, coloringMask)) { if (hit.collider.GetComponent <ColorProperties>() != null) { _color = hit.collider.GetComponent <ColorProperties>().GetColor(); hit.collider.GetComponent <ColorProperties>().PlayColorName(); if (SceneManager.GetActiveScene().name == "AR_Cardboard") { if (gameManager != null) { if (gameManager.currentTrackedPlayAudioTarget != null) { currentTrackedAnimal = gameManager.currentTrackedPlayAudioTarget; if (currentTrackedAnimal.GetComponentInChildren <Renderer>() != null) { currentTrackedAnimal.GetComponentInChildren <Renderer>().sharedMaterial.color = _color; } } } } else if (SceneManager.GetActiveScene().name == "AR_Scene") { if (gameManagerAR != null) { if (gameManagerAR.currentTrackedPlayAudioTarget != null) { currentTrackedAnimal = gameManagerAR.currentTrackedPlayAudioTarget; if (currentTrackedAnimal.GetComponentInChildren <Renderer>() != null) { currentTrackedAnimal.GetComponentInChildren <Renderer>().sharedMaterial.color = _color; } } } } } } } #elif !UNITY_EDITOR foreach (Touch t in Input.touches) { if (t.phase == TouchPhase.Began) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(t.position); if (Physics.Raycast(ray, out hit, Mathf.Infinity, coloringMask)) { if (hit.collider.GetComponent <ColorProperties>() != null) { _color = hit.collider.GetComponent <ColorProperties> ().GetColor(); hit.collider.GetComponent <ColorProperties>().PlayColorName(); if (SceneManager.GetActiveScene().name == "AR_Cardboard") { if (gameManager != null) { if (gameManager.currentTrackedPlayAudioTarget != null) { currentTrackedAnimal = gameManager.currentTrackedPlayAudioTarget; if (currentTrackedAnimal.GetComponentInChildren <Renderer>() != null) { currentTrackedAnimal.GetComponentInChildren <Renderer>().sharedMaterial.color = _color; } } } } else if (SceneManager.GetActiveScene().name == "AR_Scene") { if (gameManagerAR != null) { if (gameManagerAR.currentTrackedPlayAudioTarget != null) { currentTrackedAnimal = gameManagerAR.currentTrackedPlayAudioTarget; if (currentTrackedAnimal.GetComponentInChildren <Renderer>() != null) { currentTrackedAnimal.GetComponentInChildren <Renderer>().sharedMaterial.color = _color; } } } } } } } } #endif } }
void GetCurrentTrackableObjects() { // Get the StateManager StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); noOfActiveTrackables = activeTrackables.Count(); // Iterate through the list of active trackables foreach (TrackableBehaviour tb in activeTrackables) { //Debug.Log("Trackable: " + tb.TrackableName); if (tb.TrackableName != "ActionCard" && tb.TrackableName != "groundcard" && tb.TrackableName != "BigMarker") { currentTrackedPlayAudioTarget = tb; cardTrackingTimer += Time.deltaTime; if (!playedAnimalNameOnce && cardTrackingTimer >= 1.75f) { if (currentTrackedPlayAudioTarget.transform.GetChild(0) != null) { Debug.Log(currentTrackedPlayAudioTarget.TrackableName + " Play Audio script found!"); // playAudio = currentTrackedPlayAudioTarget.transform.GetChild(0).GetComponent<PlayAudio>(); // playAudio.PlayAnimalNameClipOnClick(); Invoke("CanAnswerQuestions", 2f); } playedAnimalNameOnce = true; } } currentTrackedTarget = tb; if (currentTrackedTarget.GetComponentInChildren <TouchControls>()) { currentTrackedTarget.GetComponentInChildren <TouchControls>().objectVisible = true; } if (currentTrackedTarget.TrackableName == "ActionCard" && noOfActiveTrackables == 1) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(false); } } else { if (!takingScreenshot) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(true); } } } foreach (GameObject obj in objects) { GameObject ro = obj.GetComponent <SnappedObject>().refObject; if (ro != null) { if (ro.activeSelf) { ro.SetActive(false); } } } trackableObjects.Add(currentTrackedTarget); currentTrackedTargetName = currentTrackedTarget.TrackableName; /* if (!source.isPlaying && !breakOutOfQuestions && currentTrackedTargetName != "ActionCard" && currentTrackedTargetName != "groundcard" && canAnswerQuestionsNow) * { * if (!scannedCurrentTrackable && cardTrackingTimer >= timeBeforeQuestionsPlayRightOrWRong) * { * * if (!answeredCorrectly) * { * if (Time.time > msTimeBeforePlayingCorrectOrWrong) * { * if (currentTrackedTargetName == names[randomIndex]) * { * switch (currentChoosenLanguage) * { * case "English": * source.clip = answers[0]; * break; * case "Chinese": * source.clip = answers[2]; * break; * default: * source.clip = answers[0]; * break; * } * * * * source.Play(); * canAnswerQuestionsNow = false; * answeredCorrectly = true; * } * else * { * switch (currentChoosenLanguage) * { * case "English": * source.clip = answers[1]; * break; * case "Chinese": * source.clip = answers[3]; * break; * default: * source.clip = answers[1]; * break; * } * * * * source.Play(); * canAnswerQuestionsNow = false; * } * * scannedCurrentTrackable = true; * } * } * } * }*/ } }
void GetCurrentTrackableObjects() { // Get the StateManager StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); //noOfActiveTrackables = activeTrackables.Count(); // Iterate through the list of active trackables foreach (TrackableBehaviour tb in activeTrackables) { if (tb.TrackableName != "action-card" && tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { currentTrackedPlayAudioTarget = tb; animalNameTimer += Time.deltaTime; if (currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() != null) { playAudio = currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>(); } if (!playedAnimalNameOnce && animalNameTimer >= passedTime) { playedAnimalNameOnce = true; playedAnimalVoiceOnce = false; if (playAudio != null) { playAudio.PlayAnimalNameClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } } if (playedAnimalNameOnce && animalNameTimer >= passedTime) { if (playAudio != null) { if (playAudio.indexNumber == 0 && !playedAnimalVoiceOnce) { playedAnimalVoiceOnce = true; playAudio.PlayAnimalSoundClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } else { if (playAudio.indexNumber > playAudio.maxArrayLength - 1) { playedAnimalNameOnce = false; playAudio.indexNumber = 0; } else { playAudio.PlayInfoClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } } } } } if (tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { bigMarkerTrackable = tb; } currentTrackedTarget = tb; trackableObjects.Add(currentTrackedTarget); } }