bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { hitPoint = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foundSquare.transform.position = hitPoint; foundSquare.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Vector3 hitPosition = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Quaternion rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); spawnedObjects.Add(Instantiate(hitPrefab, hitPosition, rotation)); return(true); } } return(false); }
// Use this for initialization void Start() { #if !UNITY_EDITOR Application.targetFrameRate = 60; m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); ARKitSessionConfiguration config = new ARKitSessionConfiguration(); config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.getPointCloudData = true; config.enableLightEstimation = true; m_session.RunWithConfig(config); if (m_camera == null) { m_camera = Camera.main; } #endif }
// Use this for initialization void Start() { Input.location.Start(); mMapListPanel.SetActive(false); mSession = UnityARSessionNativeInterface.GetARSessionNativeInterface(); UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; StartARKit(); FeaturesVisualizer.EnablePointcloud(); LibPlacenote.Instance.RegisterListener(this); GameObject pmgo = GameObject.FindWithTag("PaintManager"); paintManager = pmgo.GetComponent <PaintManager>(); }
public void UpdateMesh(ARPlaneAnchor arPlaneAnchor) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry { planeMesh.vertices = arPlaneAnchor.planeGeometry.vertices; planeMesh.uv = arPlaneAnchor.planeGeometry.textureCoordinates; planeMesh.triangles = arPlaneAnchor.planeGeometry.triangleIndices; lineRenderer.positionCount = arPlaneAnchor.planeGeometry.boundaryVertexCount; lineRenderer.SetPositions(arPlaneAnchor.planeGeometry.boundaryVertices); // Assign the mesh object and update it. planeMesh.RecalculateBounds(); planeMesh.RecalculateNormals(); } }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); //note we have not converted to Unity coord system yet - since we are going to pass this back to ARKit CreateEnvironmentProbe(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { selectedModel.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Debug.Log("Hit position: " + selectedModel.transform.position); selectedModel.transform.rotation = Quaternion.identity; return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count == 1) { foreach (var hitResult in hitResults) { Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.position = pos * m_ContentScale; m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
/// <summary> /// Resets ARKit or ARCore tracking to position (0,0,0) and rotation (0,0,0). /// </summary> public void ResetTracking() { // Apple iOS (ARKit) if (TeleportalPlatformInfo.IsMobileApple) { ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.Horizontal); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking); } // Google Android (ARCore) else if (TeleportalPlatformInfo.IsMobileGoogle) { LifecycleManager.Instance.DestroySession(); LifecycleManager.Instance.EnableSession(); } }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { foundSquare.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foundSquare.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); // Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", foundSquare.transform.position.x, foundSquare.transform.position.y, foundSquare.transform.position.z)); return(true); } } return(false); }
void RestartARSessionWith(ARWorldMap worldMap) { if (worldMap != null) { Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent); UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true; var config = arCameraManager.sessionConfiguration; config.worldMap = worldMap; UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking; Debug.Log("Restarting session with worldMap"); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOption); } }
// Update is called once per frame void Update() { if (trackedCamera != null && sessionStarted) { Matrix4x4 cameraPose = UnityARSessionNativeInterface.GetARSessionNativeInterface().GetCameraPose(); trackedCamera.transform.localPosition = UnityARMatrixOps.GetPosition(cameraPose); trackedCamera.transform.localRotation = UnityARMatrixOps.GetRotation(cameraPose); //Debug.Log ("device cam rotation: " + trackedCamera.transform.localRotation + " device cam position: " + trackedCamera.transform.localPosition); //if (camManager.EyeCamUsed) { // trackedCamera.transform.localRotation = new Quaternion (0, 0, 0, -1); // don't use device rotation (landscape, portrait etc) //} trackedCamera.projectionMatrix = UnityARSessionNativeInterface.GetARSessionNativeInterface().GetCameraProjection(); } }
public override void UpdateCamera(Camera camera) { camera.projectionMatrix = nativeInterface.GetCameraProjection(); if (!m_BackgroundRendering) { return; } ARTextureHandles handles = UnityARSessionNativeInterface.GetARSessionNativeInterface().GetARVideoTextureHandles(); if (handles.textureY == System.IntPtr.Zero || handles.textureCbCr == System.IntPtr.Zero) { m_CanRenderBackground = false; return; } m_CanRenderBackground = true; BackgroundRendering = m_BackgroundRendering; Resolution currentResolution = Screen.currentResolution; // Texture Y if (_videoTextureY == null) { _videoTextureY = Texture2D.CreateExternalTexture(currentResolution.width, currentResolution.height, TextureFormat.R8, false, false, (System.IntPtr)handles.textureY); _videoTextureY.filterMode = FilterMode.Bilinear; _videoTextureY.wrapMode = TextureWrapMode.Repeat; m_ClearMaterial.SetTexture("_textureY", _videoTextureY); } // Texture CbCr if (_videoTextureCbCr == null) { _videoTextureCbCr = Texture2D.CreateExternalTexture(currentResolution.width, currentResolution.height, TextureFormat.RG16, false, false, (System.IntPtr)handles.textureCbCr); _videoTextureCbCr.filterMode = FilterMode.Bilinear; _videoTextureCbCr.wrapMode = TextureWrapMode.Repeat; m_ClearMaterial.SetTexture("_textureCbCr", _videoTextureCbCr); } _videoTextureY.UpdateExternalTexture(handles.textureY); _videoTextureCbCr.UpdateExternalTexture(handles.textureCbCr); m_ClearMaterial.SetMatrix("_DisplayTransform", m_DisplayTransform); }
public void PlaceOnCamera(Camera camera) { Vector3 viewPortPos = Vector3.zero; switch (_component) { case ARKitOriginComponent.Origin: viewPortPos = Camera.main.ScreenToViewportPoint(Vector3.forward); break; case ARKitOriginComponent.Right: viewPortPos = Camera.main.ScreenToViewportPoint(new Vector3(0.5f, 0.0f, 1.0f)); break; case ARKitOriginComponent.Forward: viewPortPos = Camera.main.ScreenToViewportPoint(new Vector3(0.0f, 0.5f, 1.0f)); break; } Vector3 screenPosition = Camera.main.ScreenToViewportPoint(viewPortPos); ARPoint point = new ARPoint { x = screenPosition.x, y = screenPosition.y }; // prioritize reults types ARHitTestResultType[] resultTypes = { ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, ARHitTestResultType.ARHitTestResultTypeHorizontalPlane, ARHitTestResultType.ARHitTestResultTypeFeaturePoint }; foreach (ARHitTestResultType resultType in resultTypes) { UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); List <ARHitTestResult> hitResults = session.HitTest(point, resultType); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); } } } }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Unity: Got hit!"); controller.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); //controller.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Debug.Log("Unity: " + controller.transform.position + " ; " + controller.transform.eulerAngles); return(true); } } return(false); }
public void ExampletButtonPressed(UnityARVideoFormat videoFormat) { UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); var config = new ARKitFaceTrackingConfiguration(); if (config.IsSupported) { config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.enableLightEstimation = true; config.videoFormat = videoFormat.videoFormatPtr; Application.targetFrameRate = videoFormat.framesPerSecond; UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking; session.RunWithConfigAndOptions(config, runOption); } }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); ResetRotateAnim(); rb.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); rb.rotation = Quaternion.LookRotation(GetLookVector()); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { hitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); hitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); catControl.MoveTo(hitTransform.position, -0.15f); Show(); return(true); } } return(false); }
// Use this for initialization protected override void Start() { base.Start(); m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); Application.targetFrameRate = 60; #if IS_SLAM_APP StartArSession(); #else #endif if (m_camera == null) { m_camera = Camera.main; } }
public void startbtn() { shapeManager = GetComponent <ShapeManager>(); Input.location.Start(); // Start ARKit using the Unity ARKit Plugin mSession = UnityARSessionNativeInterface.GetARSessionNativeInterface(); UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; // Debug.Log("bool true"+ mFrameUpdated); StartARKit(); FeaturesVisualizer.EnablePointcloud(); // Optional - to see the point features LibPlacenote.Instance.RegisterListener(this); // Register listener for onStatusChange and OnPose notifications.text = "location" + Input.location.lastData.latitude.ToString() + Input.location.lastData.longitude.ToString(); Debug.Log("btn click start"); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); GameObject newFood = GameObject.Instantiate(foodTemplate); newFood.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foods.Add(newFood); return(true); } } return(false); }
public void ResetSceneConfig() { ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); config.planeDetection = MAR.planeDetection; config.alignment = MAR.startAlignment; config.getPointCloudData = MAR.getPointCloud; config.enableLightEstimation = MAR.enableLightEstimation; config.enableAutoFocus = MAR.enableAutoFocus; if (MAR.detectionImages != null) { config.arResourceGroupName = MAR.detectionImages.resourceGroupName; } //m_session.RunWithConfig (config); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking); }
private void Start() { #if UNITY_IOS // Ensure that ARkit reset the tracking when the scene gets restarted UnityARCameraManager arkitCameraManager = FindObjectOfType <UnityARCameraManager>(); UnityARSessionRunOption options = new UnityARSessionRunOption(); options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking; UnityARSessionNativeInterface nativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface(); ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); config.planeDetection = arkitCameraManager.planeDetection; config.alignment = arkitCameraManager.startAlignment; config.getPointCloudData = arkitCameraManager.getPointCloud; config.enableLightEstimation = arkitCameraManager.enableLightEstimation; nativeInterface.RunWithConfigAndOptions(config, options); #endif }
bool HitTestWithResultType1(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { //TODO: get the position and rotations to spawn the hat. Done: Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Quaternion rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); spawnedObjects.Add(Instantiate(Terrain, pos, rotation)); // in order to use for shuffling return(true); } } return(false); }
private void Start() { m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); Application.targetFrameRate = 60; ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration(); // ARではなくてAvatarシステムとかだと非Gravityが楽 config.alignment = UnityARAlignment.UnityARAlignmentCamera; config.enableLightEstimation = true; if (config.IsSupported) { m_session.RunWithConfig(config); UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated; } }
private void Update() { // We only classify a new image if no other vision requests are in progress if (_vision.InProgress) { return; } // Use the Y plane of the YCbCr texture to render the current camera frame. ARTextureHandles handles = UnityARSessionNativeInterface.GetARSessionNativeInterface().GetARVideoTextureHandles(); if (handles.textureY != System.IntPtr.Zero) { // This is the call where we pass in the handle to the metal texture to be analysed _vision.EvaluateBuffer(handles.textureY, ImageDataType.MetalTexture); } }
// Update is called once per frame void Update() { #if UNITY_EDITOR //we will only use this script on the editor side, though there is nothing that would prevent it from working on device if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //we'll try to hit one of the plane collider gameobjects that were generated by the plugin //effectively similar to calling HitTest with ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent if (Physics.Raycast(ray, out hit, maxRayDistance, collisionLayer)) { CreateBall(new Vector3(hit.point.x, hit.point.y + createHeight, hit.point.z)); //we're going to get the position from the contact point Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", hit.point.x, hit.point.y, hit.point.z)); } } #else if (Input.touchCount > 0) { var touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { var screenPosition = Camera.main.ScreenToViewportPoint(touch.position); ARPoint point = new ARPoint { x = screenPosition.x, y = screenPosition.y }; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Vector3 position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); CreateBall(new Vector3(position.x, position.y + createHeight, position.z)); break; } } } } #endif }
/// <summary> /// Performs a Raycast against a plane. /// </summary> /// <param name="camera">The AR camera being used.</param> /// <param name="x">The x screen position.</param> /// <param name="y">The y screen position.</param> /// <param name="hitPose">The resulting hit pose if the method returns <c>true</c>.</param> /// <returns><c>true</c> if a plane was hit. Otherwise <c>false</c>.</returns> public bool RaycastPlane(Camera camera, float x, float y, out Pose hitPose) { hitPose = new Pose(); #if ARCORE_IOS_SUPPORT var session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); var viewportPoint = camera.ScreenToViewportPoint(new Vector2(x, y)); ARPoint arPoint = new ARPoint { x = viewportPoint.x, y = viewportPoint.y }; m_HitResultList = session.HitTest(arPoint, ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent); if (m_HitResultList.Count > 0) { int minDistanceIndex = 0; for (int i = 1; i < m_HitResultList.Count; i++) { if (m_HitResultList[i].distance < m_HitResultList[minDistanceIndex].distance) { minDistanceIndex = i; } } hitPose.position = UnityARMatrixOps.GetPosition(m_HitResultList[minDistanceIndex].worldTransform); // Original ARKit hit pose is the plane rotation. Quaternion planeRotation = UnityARMatrixOps.GetRotation( m_HitResultList[minDistanceIndex].worldTransform); // Try to match the hit rotation to the one ARCore uses. Vector3 planeNormal = planeRotation * Vector3.up; Vector3 rayDir = camera.ViewportPointToRay(viewportPoint).direction; Vector3 planeProjection = Vector3.ProjectOnPlane(rayDir, planeNormal); Vector3 forwardDir = -planeProjection.normalized; Quaternion hitRotation = Quaternion.LookRotation(forwardDir, planeNormal); hitPose.rotation = hitRotation; return(true); } #endif return(false); }
void Update() { List <ARHitTestResult> hitResults; ARPoint point; //float scale; if (Input.touchCount > 0 && anchor != null) { var touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { Vector2 center = new Vector2(Screen.width / 2, Screen.height / 2); Vector3 screenPosition = Camera.main.ScreenToViewportPoint(center); point.x = screenPosition.x; point.y = screenPosition.y; //Vector2 edge = new Vector2 (Screen.width, Screen.height / 2); //Vector3 screenEdge = Camera.main.ScreenToViewportPoint (edge); //scale = screenPosition.x - screenEdge.x; hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent); if (hitResults.Count == 0) { hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeHorizontalPlane); } if (hitResults.Count == 0) { hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeFeaturePoint); } if (hitResults.Count > 0) { anchor.position = UnityARMatrixOps.GetPosition(hitResults [0].worldTransform); anchor.rotation = UnityARMatrixOps.GetRotation(hitResults [0].worldTransform); //Debug.Log("ARHitHandler scale: " + scale); //anchor.localScale = new Vector3(scale, scale, scale); controller.ToggleAnchor(); } } } }
protected override void Update() { base.Update(); LinkedList <ARPlaneAnchorGameObject> arpags = unityARAnchorManager.GetCurrentPlaneAnchors(); Touch touch; if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } Vector3 screenPosition = mainCamera.ScreenToViewportPoint(touch.position); ARPoint point = new ARPoint { x = screenPosition.x, y = screenPosition.y }; // prioritize reults types ARHitTestResultType[] resultTypes = { ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, // if you want to use infinite planes use this: //ARHitTestResultType.ARHitTestResultTypeExistingPlane, ARHitTestResultType.ARHitTestResultTypeEstimatedHorizontalPlane, ARHitTestResultType.ARHitTestResultTypeEstimatedVerticalPlane, ARHitTestResultType.ARHitTestResultTypeFeaturePoint //ARHitTestResultType.ARHitTestResultTypeFeaturePoint }; for (int i = 0; i < resultTypes.Length; ++i) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes[i]); if (hitResults.Count > 0) { Matrix4x4 matrix = hitResults[0].worldTransform; var touchedObject = Instantiate(AppearTouchPrefab, UnityARMatrixOps.GetPosition(matrix), UnityARMatrixOps.GetRotation(matrix)); touchedObject.transform.LookAt(mainCamera.transform); touchedObject.transform.rotation = Quaternion.Euler(0.0f, touchedObject.transform.rotation.eulerAngles.y, touchedObject.transform.rotation.z); touchedObject.transform.parent = fieldObjectAnchorRoot.transform; break; } } }