void InitializeARKitFaceTracking(serializableARKitInit sai) { #if !UNITY_EDITOR //get the config and runoption from editor and use them to initialize arkit for facetracking on device Application.targetFrameRate = 60; m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); ARKitFaceTrackingConfiguration config = sai.config; UnityARSessionRunOption runOptions = sai.runOption; m_session.RunWithConfigAndOptions(config, runOptions); UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; //UnityARSessionNativeInterface.ARFaceAnchorAddedEvent += ARFaceAnchorAdded; //UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += ARFaceAnchorUpdated; //UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += ARFaceAnchorRemoved; #endif }
//static private bool TryHitWithResultType(ARPoint point, ARHitTestResultType resultTypes) { var hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { pose.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); pose.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
void EditorDisconnected(int playerID) { if (editorID == playerID) { editorID = -1; } DisconnectFromEditor(); #if !UNITY_EDITOR if (m_session != null) { m_session.Pause(); m_session = null; } #endif }
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("cups!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { var overScene = CanvasManager.SCENE_UNDER_CANVAS; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0 && !mapWasShown && planeAppeared && !overScene) { mapWasShown = true; foreach (var hitResult in hitResults) { m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); m_HitTransform.localScale = new Vector3(resultScale, resultScale, resultScale); Vector3 currAngle = m_HitTransform.eulerAngles; m_HitTransform.LookAt(Camera.main.transform); m_HitTransform.eulerAngles = new Vector3(currAngle.x, m_HitTransform.eulerAngles.y + 180f, currAngle.z); Transform map; for (int i = 0; i < m_HitTransform.childCount; i++) { map = m_HitTransform.GetChild(i); if (map.name == "Map") { MAP = map.gameObject; MAP.GetComponent <Animator>().SetInteger("mapAnimTransition", SHOW_MAP_ANIM); spawnScript = MAP.GetComponent <SpawnOnMap> (); m_HitTransform.gameObject.GetComponent <LeanScale>().enabled = true; if (CanvasController.isFirstSession) { ccontroller.show_info_Button(); } } } generate_script.getManager().HidePrefabs(); ccontroller.hide_about_map_text(); ccontroller.show_screenShot_btn(); ccontroller.show_reload_btn(); return(true); } } return(false); }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer 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!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer 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!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.position += new Vector3(0f, bounceHeight, 0f); //m_HitTransform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform); m_HitTransform.rotation = Random.rotation; return(true); } } return(false); }
void EditorDisconnected(int playerID) { if (editorID == playerID) { editorID = -1; } DisconnectFromEditor(); Screen.sleepTimeout = SleepTimeout.SystemSetting; #if !UNITY_EDITOR if (m_session != null) { m_session.Pause(); m_session = null; } #endif }
void InitializeARKit(MessageEventArgs mea) { Debug.Log("init ARKit"); #if !UNITY_EDITOR Application.targetFrameRate = 60; m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); ARKitWorldTackingSessionConfiguration config = new ARKitWorldTackingSessionConfiguration(); config.planeDetection = UnityARPlaneDetection.Horizontal; config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.getPointCloudData = true; config.enableLightEstimation = true; m_session.RunWithConfig(config); UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; UnityARSessionNativeInterface.ARAnchorAddedEvent += ARAnchorAdded; UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated; UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved; #endif }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); // see if any valid places nearby to put kitten if (hitResults.Count > 0) // if there's a valid place to put the kitten { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); // move the kitten to the first valid position where the user dragged to m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); // adjust rotation as necessary m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
public void OnPreRender() { if (shouldRender) { ARTextureHandles handles = UnityARSessionNativeInterface.GetARSessionNativeInterface().GetARVideoTextureHandles(); if (handles.textureY == System.IntPtr.Zero || handles.textureCbCr == System.IntPtr.Zero) { return; } if (!bCommandBufferInitialized) { InitializeCommandBuffer(); } 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", _displayTransform); } }
bool DoARRaycast(Touch touch, ref ARHitTestResult hitOut) { var screenPosition = Camera.main.ScreenToViewportPoint(touch.position); ARPoint point = new ARPoint() { x = screenPosition.x, y = screenPosition.y }; var hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent); if (hitResults.Count < 1) { return(false); } hitOut = hitResults[0]; return(true); }
// The main camera is surrounded by a SphereCollider with IsTrigger set to On void OnTriggerEnter(Collider portal) { Portal logic = portal.GetComponentInParent <Portal> (); transform.position = logic.PortalCameras[1].transform.position - GetComponentInChildren <Camera>().transform.localPosition; if (logic.name == "VRDoor") { doorToReality.transform.position = new Vector3(-0.97f, 200.968f, 0.33f); doorToReality.transform.rotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(doorToReality.transform.position - mainCamera.transform.position, Vector3.up)); doorToReality.GetComponentInParent <Portal> ().Source.transform.localPosition = doorToReality.transform.position; hittest.SetActive(false); logic.gameObject.SetActive(false); } if (logic.name == "VRDoor2") { doorToReality.transform.position = new Vector3(8.83f, 904.77f, 4.0f); doorToReality.transform.rotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(doorToReality.transform.position - mainCamera.transform.position, Vector3.up)); doorToReality.GetComponentInParent <Portal> ().Source.transform.localPosition = doorToReality.transform.position; portalcamera2.SetActive(false); hittest.SetActive(false); logic.gameObject.SetActive(false); } if (logic.name == "RealWorldDoor") { hittest.SetActive(true); ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.Horizontal); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking); } if (OnPortalTransition != null) { // Emit a static OnPortalTransition event every time the camera enters a portal. The DoorManager listens for this event. OnPortalTransition(); } }
void OnGUI() { if (GUI.Button(new Rect(100, 100, 200, 50), "Stop")) { UnityARSessionNativeInterface.GetARSessionNativeInterface().Pause(); } if (GUI.Button(new Rect(300, 100, 200, 50), "Start")) { ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(alignmentOptions [currentAlignmentIndex], planeOptions[currentPlaneIndex]); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, runOptions[currentOptionIndex]); } if (GUI.Button(new Rect(100, 300, 200, 100), "Start Non-WT Session")) { ARKitSessionConfiguration sessionConfig = new ARKitSessionConfiguration(alignmentOptions [currentAlignmentIndex], true, true); UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfig(sessionConfig); } string runOptionStr = (currentOptionIndex == 0 ? "Full" : (currentOptionIndex == 1 ? "Tracking" : (currentOptionIndex == 2 ? "Anchors" : "None"))); if (GUI.Button(new Rect(100, 200, 150, 50), "RunOption:" + runOptionStr)) { currentOptionIndex = (currentOptionIndex + 1) % 4; } string alignmentOptionStr = (currentAlignmentIndex == 0 ? "Camera" : (currentAlignmentIndex == 1 ? "Gravity" : "GravityAndHeading")); if (GUI.Button(new Rect(300, 200, 150, 50), "AlignOption:" + alignmentOptionStr)) { currentAlignmentIndex = (currentAlignmentIndex + 1) % 3; } string planeOptionStr = currentPlaneIndex == 0 ? "Horizontal": "None"; if (GUI.Button(new Rect(500, 200, 150, 50), "PlaneOption:" + planeOptionStr)) { currentPlaneIndex = (currentPlaneIndex + 1) % 2; } }
/* * * * * * * * Private Methods * * * * * * */ bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { parentTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); parentTransform.position += new Vector3(0, 0.1f, 0); parentTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); GetMapMaterialReferences(); SetMapMaterialClipping(); mapPlane = new Plane(m_HitTransform.up, m_HitTransform.position); return(true); } } return(false); }
/// <summary> /// This should only be called once from MapsyncLb.cs /// </summary> public UnityMapsyncLibNativeInterface(string mapId, string userId, string developerKey, bool isMappingMode) { UnityARSessionNativeInterface arkit = UnityARSessionNativeInterface.GetARSessionNativeInterface(); IntPtr arSession = arkit.GetSession(); if (arSession == IntPtr.Zero) { Debug.Log("ARKit session is not initialized"); return; } _CreateMapsyncSession(arSession, mapId, userId, developerKey, isMappingMode); string unityCallbackGameObject = "MapSession"; string unityAssetLoadedCallbackFunction = "AssetReloaded"; string unityStatusUpdatedCallback = "StatusUpdated"; string unityStorePlacementCallback = "PlacementStored"; _RegisterUnityCallbacks(unityCallbackGameObject, unityAssetLoadedCallbackFunction, unityStatusUpdatedCallback, unityStorePlacementCallback); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { GameObject go = new GameObject(); go.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Vector3 p = go.transform.position; p.y += 0.3f; go.transform.position = p; go.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); // Create new sphere Instantiate(sphere, go.transform); return(true); } } return(false); }
private static void _frame_update(internal_UnityARCamera camera) { UnityARCamera unityARCamera = default(UnityARCamera); unityARCamera.projectionMatrix = camera.projectionMatrix; unityARCamera.worldTransform = camera.worldTransform; unityARCamera.trackingState = camera.trackingState; unityARCamera.trackingReason = camera.trackingReason; unityARCamera.videoParams = camera.videoParams; unityARCamera.lightData = camera.lightData; unityARCamera.displayTransform = camera.displayTransform; s_Camera = unityARCamera; if (camera.getPointCloudData == 1) { UpdatePointCloudData(ref s_Camera); } if (UnityARSessionNativeInterface.ARFrameUpdatedEvent != null) { UnityARSessionNativeInterface.ARFrameUpdatedEvent(s_Camera); } }
//private bool test = false; //private Vector3 original = new Vector3(0.025f, 0.025f, 0.025f); //private Vector3 changed = new Vector3(0.05f, 0.05f, 0.05f); bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { Debug.Log("Got hit!"); foreach (var hitResult in hitResults) { m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Debug.Log(string.Format("HitTest::: x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); // Make the portal to always be facing camera on spawn //Vector3 currAngle = transform.eulerAngles; //transform.LookAt(Camera.main.transform); //transform.eulerAngles = new Vector3(currAngle.x, transform.eulerAngles.y, currAngle.z); return(true); } } return(false); }
void UpdatePositionIfARScrewUp(ARPlaneAnchor arPlaneAnchor) { ARPoint point = new ARPoint { x = transform.position.x, y = transform.position.z }; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeEstimatedHorizontalPlane); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { //Debug.Log ("Got hit!"); transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); //transform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform); //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", transform.position.x, transform.position.y, transform.position.z)); } } }
void InitializeARKit(serializableARKitInit sai) { #if !UNITY_EDITOR //get the config and runoption from editor and use them to initialize arkit on device Application.targetFrameRate = 60; m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); ARKitWorldTrackingSessionConfiguration config = sai.config; UnityARSessionRunOption runOptions = sai.runOption; //potentially improves framerate? //https://bitbucket.org/Unity-Technologies/unity-arkit-plugin/issues/78/remote-very-low-fps-and-repeated UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); config.planeDetection = UnityARPlaneDetection.Horizontal; var videoFormat = UnityARVideoFormat.SupportedVideoFormats()[UnityARVideoFormat.SupportedVideoFormats().Count - 1]; config.videoFormat = videoFormat.videoFormatPtr; Application.targetFrameRate = videoFormat.framesPerSecond; m_session.RunWithConfigAndOptions(config, runOptions); UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; UnityARSessionNativeInterface.ARAnchorAddedEvent += ARAnchorAdded; UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated; UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved; #endif // #if !UNITY_EDITOR // //get the config and runoption from editor and use them to initialize arkit on device // Application.targetFrameRate = 60; // m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface(); // ARKitWorldTrackingSessionConfiguration config = sai.config; // UnityARSessionRunOption runOptions = sai.runOption; // m_session.RunWithConfigAndOptions(config, runOptions); // UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; // UnityARSessionNativeInterface.ARAnchorAddedEvent += ARAnchorAdded; // UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated; // UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved; // #endif }
//Method for checking intersections 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("Hit a surface!"); //Calculate the direction Vector3 N = Camera.main.transform.position - gameObject.transform.position; //Create a look rotation to always face the camera gameObject.transform.rotation = Quaternion.LookRotation(N); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes, GameObject prefab) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); float posy = 0.5f + pos.y; pos = new Vector3(pos.x, posy, pos.z); Quaternion rot = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Instantiate(prefab, pos, rot); // Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
void OnDestroy() { if (m_VideoCommandBuffer != null) { GetComponent <Camera>().RemoveCommandBuffer(CameraEvent.BeforeForwardOpaque, m_VideoCommandBuffer); } if (UnityARSessionNativeInterface.IsARKitRemoteServer()) { UnityARSessionNativeInterface.ARFrameUpdatedEvent -= UpdateFrame; } bCommandBufferInitialized = false; if (_videoTextureY) { Destroy(_videoTextureY); } if (_videoTextureCbCr) { Destroy(_videoTextureCbCr); } }
public void AddAnchor(ARPlaneAnchor arPlaneAnchor) { if (_floorDetectionStatus == FloorDetectionStatus.Finding) { if (_debug) { debugMessage.text = "Anchor added"; } Debug.Log("New Anchor added"); // Get point of battle field by using ray from center of display to detected floor and Vector3 center = new Vector3(Screen.width / 2, Screen.height / 2, 0.5f); var screenPosition = Camera.main.ScreenToViewportPoint(center); ARPoint point = new ARPoint { x = screenPosition.x, y = screenPosition.y }; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, ARHitTestResultType.ARHitTestResultTypeExistingPlane); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { _basePoint = UnityARMatrixOps.GetPosition(hitResult.worldTransform) + _baseVector; } } // Change floor detection status to detected _floorDetectionStatus = FloorDetectionStatus.Found; Debug.Log("Floor detected"); mainMessage.text = "Detection Complete"; // Invoke StartGame() with delay Invoke("StartGame", 0.5f); } }
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!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); if (IsHorizontal) { Vector3 currAngle = PortalRoom.transform.eulerAngles; PortalRoom.transform.position = FocusEllipse.FoundEllipse.transform.position; //PortalRoom.transform.LookAt (Camera.main.transform); PortalRoom.transform.eulerAngles = new Vector3(currAngle.x, Camera.main.transform.eulerAngles.y, currAngle.z); PortalRoom.SetActive(true); PortalController.OutsidePortal(); } else { Wall.SetActive(true); ResetWall(); CanvasController.ShowResetButton(); } _isPlaced = true; CanvasController.ScanImage.SetActive(false); Debug.Log("Call hide image"); FocusEllipse.IsScanning = false; FocusEllipse.HideFoundEllipse(); 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) { Debug.Log("Got hit!"); if (isCreated == false) { m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Gametrans.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); this.gameObject.transform.position = m_HitTransform.position; this.gameObject.transform.rotation = m_HitTransform.rotation; anim = GetComponent <Animator>(); //このスクリプトがアサインされたキャラクターのアニメーターコントローラーを取得 audioSource = GetComponent <AudioSource>(); //AudioSourceを使えるようにする isCreated = true; } //if(Gametrans.position.x > gameObject.transform.position.x && Gametrans.position.z > gameObject.transform.position.z) //{ //transform.position += (Vector3.right * x + Vector3.forward * z) * Time.deltaTime; //} //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); 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) { Debug.Log("Got hit!"); Vector3 p = UnityARMatrixOps.GetPosition(hitResult.worldTransform); if (can_create_new_obj) { CreateObj(new Vector3(p.x, p.y - 0.5f, p.z)); } else { //MoveObj (new Vector3 (m_HitTransform.position.x, m_HitTransform.position.y - 0.5f, m_HitTransform.position.z)); } 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) { Debug.Log("Got hit!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); transposition = m_HitTransform.position; transorientation = m_HitTransform.rotation; spawnlogo(); //Vector3 relativePosition = transposition - GenerateImageAnchor.GenerateImageAnchorInstance.markerPosition; //Debug.Log (string.Format ("Relative Position: x:{0:0.######} y:{1:0.######} z:{2:0.######}", relativePosition.x, relativePosition.y, relativePosition.z)); //Debug.Log (string.Format(("Rotation: x:{0:0.######} y:{1:0.######} z:{2:0.######}"), transorientation.x, transorientation.y, transorientation.z)); 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) { //pontura: iosCameraManager.PlaneDetectionOFF(); Game game = m_HitTransform.gameObject.GetComponentInChildren <Game> (); game.Init(); done = true; // Debug.Log ("Got hit!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); // Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }