想做一个AR的东西,能移动一个3D cube 到AR环境的某个点上,AR用的是AR Foundation (内含AR Core)
场景中用了两个摄像机, AR camera和一个辅助camera, 渲染了不同的层,辅助camera渲染的这个3Dcube,
现在想通过点击场景中生成的AR Plane上某个点,将cube生成在那个位置上,但是总感觉不对呢
这段代码哪里可以修改
if (_arRaycastManager.Raycast(touchPosition, _arRaycastHits, TrackableType.PlaneWithinPolygon)) { Pose _hitPose = _arRaycastHits[0].pose; Debug.Log(_hitPose.position.ToString()); if (spawnGameObject != null && !_isTouchingScreen && _touch.phase == TouchPhase.Ended) { Debug.Log("touch ended"); _cubeCamera.cullingMask &= ~(1 << 8); _arCamera.cullingMask |= (1 << 8); _cube.transform.localScale = _resetCubeScale; Debug.Log(_cube.transform.localScale); spawnGameObject.transform.position = _hitPose.position; } }