void Update() { if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT) { //shadowRenderer.enabled = chairRenderer.enabled = (IsPlaced || PlaneManager.GroundPlaneHitReceived); chairRenderer.enabled = false; shadowRenderer.enabled = false; EnablePreviewModeTransparency(!IsPlaced); if (!IsPlaced) { UtilityHelper.RotateTowardCamera(gameObject); } } else { //shadowRenderer.enabled = chairRenderer.enabled = IsPlaced; } if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT && IsPlaced) { m_RotationIndicator.SetActive(Input.touchCount == 2); m_TranslationIndicator.SetActive( (TouchHandler.IsSingleFingerDragging || TouchHandler.IsSingleFingerStationary) && !m_GroundPlaneUI.IsCanvasButtonPressed()); if (TouchHandler.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraToPlaneRay, out cameraToPlaneHit)) { if (cameraToPlaneHit.collider.gameObject.name == (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name)) { gameObject.PositionAt(cameraToPlaneHit.point); } } } } } else { m_RotationIndicator.SetActive(false); m_TranslationIndicator.SetActive(false); } }
} //END CallSetFusionProviderEvent #endregion #region GET ACTIVE FUSION PROVIDER EVENT //---------------------------------// private void CallGetActiveFusionProviderEvent() //---------------------------------// { #if VUFORIA FusionProviderType fusionProviderType = VuforiaRuntimeUtilities.GetActiveFusionProvider(); if( onFusionProviderTypeFound != null) { onFusionProviderTypeFound.Invoke( fusionProviderType ); } if (onFusionProviderTypeFoundString != null) { onFusionProviderTypeFoundString.Invoke( fusionProviderType.ToString() ); } #else Debug.LogError("BlockEventVuforia.cs CallGetActiveFusionProviderEvent() ERROR: Unable to make calls to Vuforia API. Missing scripting define symbol 'VUFORIA' in Project Settings"); #endif } //END CallGetActiveFusionProviderEvent
protected virtual void Start() { VuforiaApplication.Instance.OnVuforiaInitialized += AfterInitialization; if (FlashToggle != null) { // Flash is not supported on ARCore Devices FlashToggle.interactable = !( Application.platform == RuntimePlatform.Android && VuforiaRuntimeUtilities.GetActiveFusionProvider() == FusionProviderType.PLATFORM_SENSOR_FUSION ); } VuforiaApplication.Instance.OnVuforiaStarted += AppResumedUpdateUI; }
void Start() { objectRenderer = GetComponent <MeshRenderer>(); objectMaterial = Resources.Load <Material>("defaultMat"); m_GroundPlaneUI = FindObjectOfType <GroundPlaneTestUI>(); // Enable floor collider if running on device; Disable if running in PlayMode Floor.gameObject.SetActive(!VuforiaRuntimeUtilities.IsPlayMode()); mainCamera = Camera.main; }
void Update() { if (!VuforiaRuntimeUtilities.IsPlayMode() && !AnchorExists) { AnchorExists = DoAnchorsExist(); } GroundPlaneHitReceived = (AutomaticHitTestFrameCount == Time.frameCount); if (m_Playmat.IsPlaced) { debugText.SetText("(" + m_PlaymatAugmentation.transform.position.x + "," + m_PlaymatAugmentation.transform.position.y + "," + m_PlaymatAugmentation.transform.position.z + ")"); } }
protected override void Start() { base.Start(); this.canvasGroup = GetComponentInChildren <CanvasGroup>(); this.fadeRange = VuforiaRuntimeUtilities.IsPlayMode() ? new Vector2(0.5f, 0.6f) : new Vector2(0.9f, 1.0f); VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted); if (this.mTrackableBehaviour is VuMarkBehaviour) { this.vumarkBehaviour = (VuMarkBehaviour)this.mTrackableBehaviour; this.vumarkBehaviour.RegisterVuMarkTargetAssignedCallback(OnVuMarkTargetAssigned); this.vumarkBehaviour.RegisterVuMarkTargetLostCallback(OnVuMarkTargetLost); } }
void SetupFloor() { if (VuforiaRuntimeUtilities.IsPlayMode()) { this.floorName = "Emulator Ground Plane"; } else { this.floorName = "Floor"; GameObject floor = new GameObject(this.floorName, typeof(BoxCollider)); floor.transform.SetParent(this.chair.transform.parent); floor.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); floor.transform.localScale = Vector3.one; floor.GetComponent <BoxCollider>().size = new Vector3(100f, 0, 100f); } }
public void HandleInteractiveHitTest(HitTestResult result) { // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. Debug.Log("HandleInteractiveHitTest() called."); m_PlacementPreview.SetActive(false); if (result == null) { Debug.LogError("Invalid Hit Test."); return; } if (m_PositionalDeviceTracker != null && m_PositionalDeviceTracker.IsActive) { if (m_PlacementAnchor == null || TouchHandler.DoubleTap) { DestroyAnchors(); m_PlacementAnchor = m_PositionalDeviceTracker.CreatePlaneAnchor("MyPlacementAnchor_" + (++m_AnchorCounter), result); m_PlacementAnchor.name = "PlacementAnchor"; if (!VuforiaRuntimeUtilities.IsPlayMode()) { m_Floor.position = m_PlacementAnchor.transform.position; } m_PlacementAugmentation.transform.SetParent(m_PlacementAnchor.transform); m_PlacementAugmentation.transform.localPosition = Vector3.zero; } if (!m_PlacementAugmentation.activeInHierarchy) { Debug.Log("Setting Placement Augmentation to Active"); // On initial placement, unhide the augmentation m_PlacementAugmentation.SetActive(true); Debug.Log("Positioning Placement Augmentation at: " + result.Position); // parent the augmentation to the anchor m_PlacementAugmentation.transform.SetParent(m_PlacementAnchor.transform); m_PlacementAugmentation.transform.localPosition = Vector3.zero; RotateTowardCamera(m_PlacementAugmentation); m_TouchHandler.enableRotation = true; } } }
void Awake() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && DestroyTrackableBehaviourMeshAndRenderer) { MeshRenderer meshRenderer = GetComponent <MeshRenderer>(); MeshFilter meshFilter = GetComponent <MeshFilter>(); if (meshRenderer) { Destroy(meshRenderer); } if (meshFilter) { Destroy(meshFilter); } } }
private List <string> GetFilePaths(string directoryPath, string fileType) { List <string> list = new List <string>(); if (Directory.Exists(directoryPath)) { string[] files = Directory.GetFiles(directoryPath); for (int i = 0; i < files.Length; i++) { string text = files[i]; if (VuforiaRuntimeUtilities.StripExtensionFromPath(text).IndexOf(fileType, StringComparison.OrdinalIgnoreCase) == 0) { list.Add(text); } } } return(list); }
void Start() { this.mainCamera = Camera.main; this.groundPlaneUI = FindObjectOfType <GroundPlaneUI>(); this.chairShadowRenderer = this.chairShadow.GetComponent <MeshRenderer>(); SetupMaterials(); SetupFloor(); this.augmentationScale = VuforiaRuntimeUtilities.IsPlayMode() ? 0.1f : this.productSize; this.productScale = new Vector3(this.augmentationScale, this.augmentationScale, this.augmentationScale); //this.chair.transform.localScale = this.productScale; }
void DestroyAnchors() { if (!VuforiaRuntimeUtilities.IsPlayMode()) { IEnumerable <TrackableBehaviour> trackableBehaviours = m_StateManager.GetActiveTrackableBehaviours(); string destroyed = "Destroying: "; foreach (TrackableBehaviour behaviour in trackableBehaviours) { Debug.Log(behaviour.name + "\n" + behaviour.Trackable.Name + "\n" + behaviour.Trackable.ID + "\n" + behaviour.GetType()); if (behaviour is AnchorBehaviour) { // First determine which mode (Plane or MidAir) and then delete only the anchors for that mode // Leave the other mode's anchors intact // PlaneAnchor_<GUID> // Mid AirAnchor_<GUID> destroyed += "\nGObj Name: " + behaviour.name + "\nTrackable Name: " + behaviour.Trackable.Name + "\nTrackable ID: " + behaviour.Trackable.ID + "\nPosition: " + behaviour.transform.position.ToString(); m_StateManager.DestroyTrackableBehavioursForTrackable(behaviour.Trackable); m_StateManager.ReassociateTrackables(); } } Debug.Log(destroyed); } else { m_PlacementAugmentation.transform.parent = null; DestroyObject(m_PlacementAnchor); } }
void Update() { /* * if(m_PlaneFinder != null){ * m_PlaneFinder.enabled = !IsPointerOverUIObject(); * } */ if (!VuforiaRuntimeUtilities.IsPlayMode() && !AnchorExists) { AnchorExists = DoAnchorsExist(); } GroundPlaneHitReceived = (AutomaticHitTestFrameCount == Time.frameCount); SetSurfaceIndicatorVisible( GroundPlaneHitReceived && (planeMode == PlaneMode.GROUND || (planeMode == PlaneMode.PLACEMENT && Input.touchCount == 0))); }
// Disable image target rendering private void TurnOffImage() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && turnOffRendering != TurnOffRendering.Neither && (turnOffRendering == TurnOffRendering.PlayModeAndDevice || Application.isEditor)) { MeshRenderer meshRenderer = GetComponent <MeshRenderer>(); MeshFilter meshFilter = GetComponent <MeshFilter>(); if (meshRenderer) { Destroy(meshRenderer); } if (meshFilter) { Destroy(meshFilter); } } }
protected virtual void Start() { this.cameraSettings = FindObjectOfType <CameraSettings>(); this.trackableSettings = FindObjectOfType <TrackableSettings>(); this.optionsConfig = FindObjectOfType <OptionsConfig>(); this.optionsMenuCanvas = GetComponentInChildren <Canvas>(true); this.deviceTrackerToggle = FindUISelectableWithText <Toggle>("Tracker"); this.autofocusToggle = FindUISelectableWithText <Toggle>("Autofocus"); this.flashToggle = FindUISelectableWithText <Toggle>("Flash"); if (this.flashToggle) { // Flash is not supported on ARCore Devices this.flashToggle.interactable = !( Application.platform == RuntimePlatform.Android && VuforiaRuntimeUtilities.GetActiveFusionProvider() == FusionProviderType.PLATFORM_SENSOR_FUSION); } VuforiaARController.Instance.RegisterOnPauseCallback(OnPaused); }
void Update() { if (PlaneManager.CurrentPlaneMode == PlaneManager.PlaneMode.PLACEMENT) { EnablePreviewModeTransparency(!this.IsPlaced); if (!this.IsPlaced) { UtilityHelper.RotateTowardCamera(this.chair); } } if (PlaneManager.CurrentPlaneMode == PlaneManager.PlaneMode.PLACEMENT && this.IsPlaced) { this.rotationIndicator.SetActive(Input.touchCount == 2); this.translationIndicator.SetActive( (TouchHandler.IsSingleFingerDragging || TouchHandler.IsSingleFingerStationary) && !this.groundPlaneUI.IsCanvasButtonPressed()); if (TouchHandler.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { if (!this.groundPlaneUI.IsCanvasButtonPressed()) { this.cameraToPlaneRay = this.mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(this.cameraToPlaneRay, out this.cameraToPlaneHit)) { if (this.cameraToPlaneHit.collider.gameObject.name == floorName) { this.chair.PositionAt(this.cameraToPlaneHit.point); } } } } } else { this.rotationIndicator.SetActive(false); this.translationIndicator.SetActive(false); } }
void Start() { Debug.Log("Start() called."); VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted); VuforiaARController.Instance.RegisterOnPauseCallback(OnVuforiaPaused); DeviceTrackerARController.Instance.RegisterTrackerStartedCallback(OnTrackerStarted); DeviceTrackerARController.Instance.RegisterDevicePoseStatusChangedCallback(OnDevicePoseStatusChanged); m_PlaneFinder.HitTestMode = HitTestMode.AUTOMATIC; m_PlacementAugmentationScale = VuforiaRuntimeUtilities.IsPlayMode() ? 0.1f : ProductSize; ProductScaleVector = new Vector3(m_PlacementAugmentationScale, m_PlacementAugmentationScale, m_PlacementAugmentationScale); m_PlacementPreview.transform.localScale = ProductScaleVector; m_PlacementAugmentation.transform.localScale = ProductScaleVector; m_GroundToggle.interactable = false; m_MidAirToggle.interactable = false; m_PlacementToggle.interactable = false; m_ResetButton.interactable = false; // Enable floor collider if running on device; Disable if running in PlayMode Floor.gameObject.SetActive(!VuforiaRuntimeUtilities.IsPlayMode()); m_IconGroundMode = Resources.Load <Sprite>("icon_ground_mode"); m_IconMidAirMode = Resources.Load <Sprite>("icon_midair_mode"); m_IconPlacementMode = Resources.Load <Sprite>("icon_placement_mode"); m_TitleMode.text = TITLE_PLACEMENT; m_PlaneModeIcon.sprite = m_IconPlacementMode; mainCamera = Camera.main; m_TouchHandler = FindObjectOfType <TouchHandler>(); m_GraphicRayCaster = FindObjectOfType <GraphicRaycaster>(); m_EventSystem = FindObjectOfType <EventSystem>(); }
void Start() { meshRenderer = GetComponent <MeshRenderer>(); chairMaterials = new Material[] { Resources.Load <Material>("ChairBody"), Resources.Load <Material>("ChairFrame") }; chairMaterialsTransparent = new Material[] { Resources.Load <Material>("ChairBodyTransparent"), Resources.Load <Material>("ChairFrameTransparent") }; ChairShadow = Resources.Load <Material>("ChairShadow"); ChairShadowTransparent = Resources.Load <Material>("ChairShadowTransparent"); m_GroundPlaneUI = FindObjectOfType <GroundPlaneUI>(); // Enable floor collider if running on device; Disable if running in PlayMode Floor.gameObject.SetActive(!VuforiaRuntimeUtilities.IsPlayMode()); mainCamera = Camera.main; m_PlacementAugmentationScale = VuforiaRuntimeUtilities.IsPlayMode() ? 0.1f : ProductSize; ProductScaleVector = new Vector3(m_PlacementAugmentationScale, m_PlacementAugmentationScale, m_PlacementAugmentationScale); gameObject.transform.localScale = ProductScaleVector; }
void UpdateVuMarkBorderOutline() { if (this.lineRenderer) { // Only enable line renderer when target becomes Extended Tracked or when running in Unity Editor. this.lineRenderer.enabled = (m_NewStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) || VuforiaRuntimeUtilities.IsPlayMode(); if (this.lineRenderer.enabled) { // If the Device Tracker is enabled and the target becomes Extended Tracked, // set the VuMark outline to green. If in Unity Editor PlayMode, set to cyan. // Note that on HoloLens, the Device Tracker is always enabled (as of Vuforia 7.2). this.lineRenderer.material.color = (m_NewStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) ? Color.green : Color.cyan; } } else { this.lineRenderer = GetComponentInChildren <LineRenderer>(); } }
// Update is called once per frame void Update() { if (m_PlacementAugmentation.activeInHierarchy) { m_RotationIndicator.SetActive(Input.touchCount == 2); m_TranslationIndicator.SetActive(TouchHandler.IsSingleFingerDragging()); if (TouchHandler.IsSingleFingerDragging() || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { if (!IsCanvasButtonPressed()) { cameraPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraPlaneRay, out cameraToPlaneHit)) { if (cameraToPlaneHit.collider.gameObject.name == (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : m_Floor.name)) { m_PlacementAugmentation.PositionAt(cameraToPlaneHit.point); } } } } } }
void UpdateClosestTarget() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && VuforiaARController.Instance.HasStarted) { Camera cam = DigitalEyewearARController.Instance.PrimaryCamera ?? Camera.main; float closestDistance = Mathf.Infinity; foreach (VuMarkBehaviour vumarkBehaviour in this.vumarkManager.GetActiveBehaviours()) { Vector3 worldPosition = vumarkBehaviour.transform.position; Vector3 camPosition = cam.transform.InverseTransformPoint(worldPosition); float distance = Vector3.Distance(Vector2.zero, camPosition); if (distance < closestDistance) { closestDistance = distance; this.closestVuMark = vumarkBehaviour.VuMarkTarget; } } if (this.closestVuMark != null && this.currentVuMark != this.closestVuMark) { var vuMarkId = GetVuMarkId(this.closestVuMark); var vuMarkDataType = GetVuMarkDataType(this.closestVuMark); var vuMarkImage = GetVuMarkImage(this.closestVuMark); var vuMarkDesc = GetVuMarkDescription(this.closestVuMark); var vuMarkName = GetNumericVuMarkDescription(this.closestVuMark); var vuMarkIcon = GetVuMarkIcon(this.closestVuMark); this.currentVuMark = this.closestVuMark; StartCoroutine(ShowPanelAfter(0.5f, vuMarkId, vuMarkDataType, vuMarkName, vuMarkDesc, vuMarkImage, vuMarkIcon)); } } }
void Start() { m_GroundPlaneUI = FindObjectOfType <GroundPlaneUI>(); // Enable floor collider if running on device; Disable if running in PlayMode Floor.gameObject.SetActive(!VuforiaRuntimeUtilities.IsPlayMode()); mainCamera = Camera.main; m_PlacementAugmentationScale = VuforiaRuntimeUtilities.IsPlayMode() ? 1f : ProductSize; ProductScaleVector = new Vector3(m_PlacementAugmentationScale, m_PlacementAugmentationScale, m_PlacementAugmentationScale); gameObject.transform.localScale = ProductScaleVector; copyShoe = GameObject.Find("CopyShoe"); shoeRenderers = copyShoe.GetComponentsInChildren <MeshRenderer>(); doesHitShoe = false; meshColliders.AddRange(copyShoe.GetComponentsInChildren <MeshCollider>()); }
void Update() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !mLoaded) { string externalPath = Application.persistentDataPath; if (mDataset == null) { // First, create the dataset ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); mDataset = tracker.CreateDataSet(); } if (mDataset.Load(externalPath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { mLoaded = true; } else { Debug.LogError("Failed to load dataset!"); } } }
void UpdateClosestTarget() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && VuforiaARController.Instance.HasStarted) { Camera cam = DigitalEyewearARController.Instance.PrimaryCamera ?? Camera.main; float closestDistance = Mathf.Infinity; foreach (VuMarkBehaviour vumarkBehaviour in this.vumarkManager.GetActiveBehaviours()) { Vector3 worldPosition = vumarkBehaviour.transform.position; Vector3 camPosition = cam.transform.InverseTransformPoint(worldPosition); float distance = Vector3.Distance(Vector2.zero, camPosition); if (distance < closestDistance) { closestDistance = distance; this.closestVuMark = vumarkBehaviour.VuMarkTarget; } } if (this.closestVuMark != null && this.currentVuMark != this.closestVuMark) { ProductInfo productInfo = new ProductInfo(); productInfo = RetrieveProductInfoForVuMarkTarget(this.closestVuMark); string name = productInfo.name; string price = string.Format("${0:0.00}", decimal.Parse(productInfo.price)); string description = productInfo.description; Sprite image = GetProductImage(this.closestVuMark); bool isGold = productInfo.golden; this.currentVuMark = this.closestVuMark; StartCoroutine(ShowPanelAfter(0.5f, name, price, description, image, isGold)); } } }
void Update() { objectRenderer.enabled = (IsPlaced); if (PlaneManagerTest.planeMode == PlaneManagerTest.PlaneMode.TGO && IsPlaced) { m_RotationIndicator.SetActive(Input.touchCount == 2); Debug.Log("Input.touchCount is " + Input.touchCount); Debug.Log("Is RotationIndicator active?" + m_RotationIndicator.activeSelf); m_TranslationIndicator.SetActive( (TGOTouchHandlerTest.IsSingleFingerDragging || TGOTouchHandlerTest.IsSingleFingerStationary) && !m_GroundPlaneUI.IsCanvasButtonPressed()); if (TGOTouchHandlerTest.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraToPlaneRay, out cameraToPlaneHit)) { if (cameraToPlaneHit.collider.gameObject.name == (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name)) { gameObject.PositionAt(cameraToPlaneHit.point); } } } } } else { m_RotationIndicator.SetActive(false); m_TranslationIndicator.SetActive(false); } }
void Update() { if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT) { // shadowRenderer.enabled = foreach (Renderer shoeRenderer in shoeRenderers) { shoeRenderer.enabled = (IsPlaced || PlaneManager.GroundPlaneHitReceived || PlaneManager.indicator); } foreach (MeshCollider meshCollider in meshColliders) { meshCollider.enabled = !doesHitShoe; } } else { foreach (Renderer shoeRenderer in shoeRenderers) { shoeRenderer.enabled = !IsPlaced; } } if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT && !IsPlaced) { m_RotationIndicator.SetActive(Input.touchCount == 2); if (m_RotationIndicator.activeSelf) { m_RotationIndicator.transform.position = copyShoe.transform.position; m_RotationIndicator.transform.position -= Vector3.up * 0.2f; } m_TranslationIndicator.SetActive( !m_GroundPlaneUI.IsCanvasUIPressed() && (TouchHandler.IsSingleFingerDragging || TouchHandler.IsSingleFingerStationary) && doesHitShoe); if (m_TranslationIndicator.activeSelf) { m_TranslationIndicator.transform.position = copyShoe.transform.position; m_TranslationIndicator.transform.position -= Vector3.up * 0.2f; } if (!m_GroundPlaneUI.IsCanvasUIPressed()) { if (Input.GetMouseButtonDown(0)) { cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraToPlaneRay, out hit)) { if (hit.collider.name.Equals(VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name)) { doesHitShoe = false; } else { doesHitShoe = true; } } } else if (TouchHandler.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraToPlaneRay, out hit)) { if (hit.collider.gameObject.name == (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name) && doesHitShoe) { gameObject.PositionAt(hit.point); } } } else if (Input.GetMouseButtonUp(0)) { doesHitShoe = false; } } } else { m_RotationIndicator.SetActive(false); m_TranslationIndicator.SetActive(false); } }
/// <summary> /// Try to pick video at tap screen position /// </summary> public void TryPickingVideo() { Debug.Log("rrrrr+fff"); if (VuforiaRuntimeUtilities.IsPlayMode()) { if (PickVideo(Input.mousePosition) != null) { Debug.LogWarning("Playing videos is currently not supported in Play Mode."); } } // Find out which video was tapped, if any currentVideo = PickVideo(Input.mousePosition); if (currentVideo != null) { if (playFullscreen) { if (currentVideo.VideoPlayer.IsPlayableFullscreen()) { //On Android, we use Unity's built in player, so Unity application pauses before going to fullscreen. //So we have to handle the orientation from within Unity. #if UNITY_ANDROID Screen.orientation = ScreenOrientation.LandscapeLeft; #endif // Pause the video if it is currently playing currentVideo.VideoPlayer.Pause(); // Seek the video to the beginning(); currentVideo.VideoPlayer.SeekTo(0.0f); // Display the busy icon currentVideo.ShowBusyIcon(); // Play the video full screen StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo)); } } else { if (currentVideo.VideoPlayer.IsPlayableOnTexture()) { // This video is playable on a texture, toggle playing/paused VideoPlayerHelper.MediaState state = currentVideo.VideoPlayer.GetStatus(); if (state == VideoPlayerHelper.MediaState.PAUSED || state == VideoPlayerHelper.MediaState.READY || state == VideoPlayerHelper.MediaState.STOPPED) { // Pause other videos before playing this one PauseOtherVideos(currentVideo); // Play this video on texture where it left off currentVideo.VideoPlayer.Play(false, currentVideo.VideoPlayer.GetCurrentPosition()); } else if (state == VideoPlayerHelper.MediaState.REACHED_END) { // Pause other videos before playing this one PauseOtherVideos(currentVideo); // Play this video from the beginning currentVideo.VideoPlayer.Play(false, 0); } else if (state == VideoPlayerHelper.MediaState.PLAYING) { // Video is already playing, pause it currentVideo.VideoPlayer.Pause(); } } else { // Display the busy icon currentVideo.ShowBusyIcon(); // This video cannot be played on a texture, play it full screen StartCoroutine(PlayFullscreenVideoAtEndOfFrame(currentVideo)); } } } }
void Update() { // Determine the number of taps // Note: Input.tapCount doesn't work on Android if (Input.touchCount > 0) { Touch touch = Input.touches[0]; if (touch.phase == TouchPhase.Began) { mTouchStartPos = touch.position; mTouchMoved = false; mTimeElapsed = 0.0f; } else { mTimeElapsed += Time.deltaTime; } if (touch.phase == TouchPhase.Moved) { if (Vector2.Distance(mTouchStartPos, touch.position) > 40) { // Touch moved too far mTouchMoved = true; } } else if (touch.phase == TouchPhase.Ended) { if (!mTouchMoved && mTimeElapsed < 1.0) { if (mTapped) { // Second tap HandleDoubleTap(); mTapped = false; } else { // Wait to see if this is a double tap mTapped = true; mTimeElapsedSinceTap = 0.0f; } } } } if (mTapped) { if (mTimeElapsedSinceTap >= 0.5f) { // Not a double tap HandleTap(); mTapped = false; } else { mTimeElapsedSinceTap += Time.deltaTime; } } // special handling in play mode: if (VuforiaRuntimeUtilities.IsPlayMode()) { if (Input.GetMouseButtonUp(0)) { if (PickVideo(Input.mousePosition) != null) { Debug.LogWarning("Playing videos is currently not supported in Play Mode."); } } } }
public AboutScreenInfo() { mTitles = new Dictionary <string, string> { { "ImageTargets", "Image Targets (from database)" }, { "InstantImageTargets", "Instant Image Targets" }, { "VuMarks", "VuMarks" }, { "CylinderTargets", "Cylinder Targets" }, { "MultiTargets", "Multi Targets" }, { "ObjectReco", "Object Reco" }, { "CloudReco", "Cloud Reco" }, { "VirtualButtons", "Virtual Buttons" }, { "ModelTargets", "Model Targets" }, { "GroundPlane", "Ground Plane" }, { "BackgroundTextureAccess", "Background Texture Access" }, { "OcclusionManagement", "Occlusion Management" }, { "Books", "Books" }, { "ModelTargetsTest", "Model Targets Test" } }; var vuforiaVersion = VuforiaApplication.GetVuforiaLibraryVersion(); var unityVersion = Application.unityVersion; Debug.Log("Vuforia Engine " + vuforiaVersion + "\nUnity " + unityVersion); var fusionProvider = VuforiaRuntimeUtilities.GetActiveFusionProvider().ToString(); var description = "\n<size=26>Description:</size>"; var keyFunctionality = "<size=26>Key Functionality:</size>"; var targets = "<size=26>Targets:</size>"; var instructions = "<size=26>Instructions:</size>"; var footer = "<size=26>Version Info:</size>" + "\n• Vuforia Engine " + vuforiaVersion + "\n• Unity " + unityVersion + "\n" + "\n<size=26>Vuforia Info:</size>" + "\n• Fusion Provider: " + fusionProvider.Replace("_", " ") + "\n" + "\n<size=26>System Info:</size>" + "\n• Device Name: " + SystemInfo.deviceName + "\n• Device Model: " + SystemInfo.deviceModel + "\n• Operating System: " + SystemInfo.operatingSystem + "\n• System Memory: " + SystemInfo.systemMemorySize + "\n• Processor Count: " + SystemInfo.processorCount + "\n• Processor Frequency: " + SystemInfo.processorFrequency + "\n" + "\n<size=26>Graphics Info:</size>" + "\n• Graphics Memory: " + SystemInfo.graphicsMemorySize + "\n• Device Name: " + SystemInfo.graphicsDeviceName + "\n• Device Vendor: " + SystemInfo.graphicsDeviceVendor + "\n• Device Type: " + SystemInfo.graphicsDeviceType + "\n• Device Version: " + SystemInfo.graphicsDeviceVersion + "\n• MultiThreaded: " + SystemInfo.graphicsMultiThreaded + "\n" + "\n<size=26>Links:</size>" + "\n• <link=https://developer.vuforia.com/legal/vuforia-developer-agreement><color=blue><u>Developer Agreement</u></color></link>" + "\n• <link=https://developer.vuforia.com/legal/privacy><color=blue><u>Privacy Policy</u></color></link>" + "\n• <link=https://developer.vuforia.com/legal/EULA><color=blue><u>Terms of Use</u></color></link>" + "\n• <link=https://developer.vuforia.com/legal/statistics><color=blue><u>Statistics</u></color></link>" + "\n\n" + "© 2021 PTC Inc. All Rights Reserved." + "\n"; var targetPDFsURL = "<link=https://library.vuforia.com/content/vuforia-library/en/articles/Solution/sample-apps-target-pdfs.html>"; // Init our Description Strings mDescriptions = new Dictionary <string, string>(); // Image Targets mDescriptions.Add( "ImageTargets", description + "\nThe Image Targets sample shows how to detect an image " + "target and render a simple 3D object on top of it." + "\n\n" + keyFunctionality + "\n• Simultaneous detection and tracking of multiple targets" + "\n• Activate Extended Tracking" + "\n• Manage camera functions: flash and continuous autofocus" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Instant Image Targets // determine if a license key has been set var licenseKeyNote = string.Empty; if (string.IsNullOrEmpty(VuforiaConfiguration.Instance.Vuforia.LicenseKey)) { licenseKeyNote = "\n<color=red>Please configure a license key in the Vuforia Configuration!</color>"; } else { licenseKeyNote = "\n<#23B200>A license key has been set.</color>"; } mDescriptions.Add( "InstantImageTargets", description + "\nThe Instant Image Targets sample shows how to create an image " + "target from image assets loaded at runtime without creating a " + "target manager database." + "\nThis sample requires a license key from:" + "\n<link=https://developer.vuforia.com/license-manager><color=blue><u>https://developer.vuforia.com/license-manager</u></color></link>" + licenseKeyNote + "\n\n" + keyFunctionality + "\n• Creating an image target from image assets" + "\n• Simultaneous detection and tracking of multiple targets" + "\n• Activate Extended Tracking" + "\n• Manage camera functions: flash and continuous autofocus" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // VuMark mDescriptions.Add( "VuMarks", description + "\nThe VuMarks sample shows how to detect and track VuMarks." + "\n\n" + keyFunctionality + "\n• Simultaneous detection and tracking of multiple VuMarks" + "\n• Load and activate a VuMark target" + "\n• Activate Extended Tracking" + "\n• Render an outline when a VuMark is detected" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point device at VuMark" + "\n• Double tap to focus" + "\n• Tap window showing VuMark ID to dismiss" + "\n\n" + footer + "\n"); // Cylinder Targets mDescriptions.Add( "CylinderTargets", description + "\nThe Cylinder Targets sample shows how to detect a cylindrical " + "target and animate a 3D object around the circumference of the cylinder." + "\n\n" + keyFunctionality + "\n• Detection and tracking of a cylinder target" + "\n• Occlusion handling" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + "Print target and wrap around a standard soda can." + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Multi Targets mDescriptions.Add( "MultiTargets", description + "\nThe Multi Targets sample shows how to detect a simple cuboid 3D shape " + "and animate a 3D object around the shape." + "\n\n" + keyFunctionality + "\n• Detection and tracking of cuboid 3D shape" + "\n• Occlusion handling" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Object Reco mDescriptions.Add( "ObjectReco", description + "\nThe Object Recognition sample shows how to recognize and track an object." + "\n\n" + keyFunctionality + "\n• Recognize and track up to 2 objects simultaneously" + "\n• Activate Extended Tracking" + "\n• Manage camera functions: flash" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Cloud Reco mDescriptions.Add( "CloudReco", description + "\nThe Cloud Reco sample shows how to use the cloud recognition service to " + "recognize targets located in a cloud database." + "\n\n" + keyFunctionality + "\n• Manage detection and tracking of cloud based image targets" + "\n• Activate Extended Tracking" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Virtual Buttons mDescriptions.Add( "VirtualButtons", description + "\nThe Virtual Buttons sample shows how the developer can define rectangular " + "regions on image targets that trigger an event when touched or occluded in " + "the camera view. The sample renders a 3D object that performs an animation when " + "one of the virtual buttons is triggered." + "\n\n" + keyFunctionality + "\n• Button occlusion event handling" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>Target PDFs</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Model Targets mDescriptions.Add( "ModelTargets", description + "\nThe Model Targets Sample shows how to detect a 3D object and " + "render a simple 3D representation over it. The sample demonstrates " + "how Standard and Advanced DataSets work." + "\n\n" + keyFunctionality + "\n• Standard Model Target: Loads a Model Target with multiple Guide Views " + "that can be cycled with the click of a button and used to pick which view " + "to detect of the physical model" + "\n• Advanced Model Target: Loads two Model Targets that have automatic " + "detection from arbitrary views and snapping of Guide Views to the physical models" + "\n• Automatic 3D object tracking after successful detection" + "\n• Extended Tracking when target is not visible in the camera view" + "\n\n" + targets + "\n• Model Target: 3D Printed Model (Mars Lander)" + "\n• Model Target: Toy Model (Polaris RZR)" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n• Switch to access a different dataset" + "\n• Mars Lander is in both datasets" + "\n• Polaris RZR is in the Advanced dataset" + "\n• Change the Detection Position if needed" + "\n\n" + footer + "\n"); // Ground Plane mDescriptions.Add( "GroundPlane", description + "\nThe Ground Plane sample demonstrates how to place " + "content on surfaces and in mid-air using anchor points." + "\n\n" + keyFunctionality + "\n• Hit testing places the Chair or the Astronaut on an intersecting plane in " + "the environment. Try this mode by pressing the Chair or Astronaut buttons." + "\n• Mid-Air anchoring places the drone on an anchor point created " + "at a fixed distance relative to the user. Select this mode by " + "pressing the Drone button." + "\n\n" + targets + "\n• None required" + "\n\n" + instructions + "\n• Launch the app and view your environment" + "\n• Look around until the indicator shows that you have found a surface" + "\n• Tap to place Chair on the ground" + "\n• Drag with one finger to move Chair along ground" + "\n• Touch and hold with two fingers to rotate Chair" + "\n• Select Ground Plane mode" + "\n• Tap to place Astronaut on the ground" + "\n• Tap again to move Astronaut to second point" + "\n• Select Mid-Air mode" + "\n• Tap to place Drone in the air" + "\n• Tap again to move Drone to the desired position" + "\n\n" + footer + "\n"); // Background Texture Access mDescriptions.Add( "BackgroundTextureAccess", description + "\nThe Background Texture Access sample shows how to use two shaders to " + "manipulate the background video. One shader turns the video into inverted " + "black-and-white and another distorts the video where you touch on the screen." + "\n\n" + keyFunctionality + "\n• Apply shaders to video background" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>ImageTarget: Fissure</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Tap and drag to distort video background" + "\n\n" + footer + "\n"); // Occlusion Management mDescriptions.Add( "OcclusionManagement", description + "\nThe Occlusion Management sample shows the use of transparent shaders to " + "let users partially look inside a real object with an occlusion effect." + "\n\n" + keyFunctionality + "\n• Manage occlusion" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>MultiTarget: MarsBox</u></color></link>" + "\n\n" + instructions + "\n• Point camera at target to view" + "\n• Double tap to focus" + "\n\n" + footer + "\n"); // Books mDescriptions.Add( "Books", description + "\nThe Books sample shows how to use the Cloud Recognition service to build a " + "simple UI to scan a sample target book cover and display info on that book." + "\n\n" + keyFunctionality + "\n• Display reco query status" + "\n• Request book info meta data based on reco response" + "\n• Render book info on target" + "\n• Transition display of book info to screen when off target" + "\n\n" + targets + "\n• " + targetPDFsURL + "<color=blue><u>ImageTargets: 3 Book Covers</u></color></link>" + "\n\n" + instructions + "\n• Point camera at sample book cover to view info" + "\n• Press close button to scan another book" + "\n\n" + footer + "\n"); // Model Targets Test mDescriptions.Add( "ModelTargetsTest", description + "\nThe Model Targets Test app allows you to detect " + "and track a Model Target out of a set of multiple targets." + #if ENABLE_MODEL_TARGETS_TEST_APP_DIAGNOSTICS " You can also record tracking data and report feedback to Vuforia." + #endif "\n\n" + keyFunctionality + "\n• Detection and tracking of Model Targets" + #if ENABLE_MODEL_TARGETS_TEST_APP_DIAGNOSTICS "\n• Collection and sending of SDK-generated data for later analysis and support" + "\n• Screenshot Capture" + #endif "\n• Tracker reset" + "\n\n" + targets + "\n• Model Target: 3D Printed Model (Mars Lander)" + "\n\n" + instructions + "\n• Point camera at 3D object to start tracking" + "\n• Double tap to focus" + "\n\n" + "<size=26>Compatible Devices:</size>" + "\n• <link=https://library.vuforia.com/articles/Solution/vuforia-fusion-supported-devices.html><color=blue><u>Vuforia Fusion Compatible Devices</u></color></link>" + "\n\n" + "<size=26>Additional Info:</size>" + "\n• <link=https://developer.vuforia.com/legal/CAD-3rd-Party-License><color=blue><u>3rd Party License: CAD</u></color></link>" + #if ENABLE_MODEL_TARGETS_TEST_APP_DIAGNOSTICS "\n• <link=https://developer.vuforia.com/legal/statistics_CAD><color=blue><u>Statistics: CAD</u></color></link>" + #endif "\n\n" + footer + "\n"); }
public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (m_StatusInfo == TrackableBehaviour.StatusInfo.NORMAL || (m_StatusInfo == TrackableBehaviour.StatusInfo.UNKNOWN && !VuforiaRuntimeUtilities.IsPlayMode())) { if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.NONE: /* * m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; * m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); * UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true); * * // Astronaut should rotate toward camera with each placement * m_PlaneAugmentation.transform.localPosition = Vector3.zero; * UtilityHelper.RotateTowardCamera(m_PlaneAugmentation); */ UtilityHelper.EnableRendererColliderCanvas(m_PlacementAugmentation, false); ResetScene(); ResetTrackers(); arRCM.FadeCanvas(false); break; /* * * case PlaneMode.GROUND: * * m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; * m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); * UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true); * * // Astronaut should rotate toward camera with each placement * m_PlaneAugmentation.transform.localPosition = Vector3.zero; * UtilityHelper.RotateTowardCamera(m_PlaneAugmentation); * * break; */ case PlaneMode.PLACEMENT: if (!m_ProductPlacement.IsPlaced || TouchHandler.DoubleTap) { m_ContentPositioningBehaviour.AnchorStage = m_PlacementAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(m_PlacementAugmentation, true); arRCM.FadeCanvas(true); } if (!m_ProductPlacement.IsPlaced) { m_ProductPlacement.SetProductAnchor(m_PlacementAnchor.transform); m_TouchHandler.enableRotation = true; } break; } } } }