-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* feat: Add cross platform camera * feat: Add level placement logic for AR * fix: Remove unused code * feat: New input system * fix: Move annas test scene to development folder
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &6800535302357286287 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 7223179368835717418} | ||
- component: {fileID: 8108863857534307628} | ||
- component: {fileID: 5474733860047409772} | ||
m_Layer: 0 | ||
m_Name: AR Session | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &7223179368835717418 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6800535302357286287} | ||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_ConstrainProportionsScale: 0 | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!114 &8108863857534307628 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6800535302357286287} | ||
m_Enabled: 0 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 3859a92a05d4f5d418cb6ca605290e74, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_AttemptUpdate: 1 | ||
m_MatchFrameRate: 1 | ||
m_TrackingMode: 2 | ||
--- !u!114 &5474733860047409772 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6800535302357286287} | ||
m_Enabled: 0 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: fa850fbd5b8aded44846f96e35f1a9f5, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &3624798292056245312 | ||
--- !u!1 &1760304300311812898 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 8109644083082424302} | ||
- component: {fileID: 8133267252169484392} | ||
- component: {fileID: 4719238613831707738} | ||
- component: {fileID: -4828068412382251286} | ||
m_Layer: 0 | ||
m_Name: LevelPositionManager | ||
m_Name: Level Placement Manager | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &8109644083082424302 | ||
--- !u!4 &4719238613831707738 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3624798292056245312} | ||
m_GameObject: {fileID: 1760304300311812898} | ||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
m_LocalPosition: {x: -6.0399113, y: -9.504788, z: 15.417434} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_ConstrainProportionsScale: 0 | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!114 &8133267252169484392 | ||
--- !u!114 &-4828068412382251286 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3624798292056245312} | ||
m_GameObject: {fileID: 1760304300311812898} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 05baa64f55a484af7924f141954d03ca, type: 3} | ||
m_Script: {fileID: 11500000, guid: 6f79d4f192ccf4e8aba8e82bd0a46ef9, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using UnityEngine.XR.ARFoundation; | ||
using UnityEngine.XR.ARSubsystems; | ||
using UnityEngine.InputSystem; | ||
|
||
public class LevelPlacementManager : MonoBehaviour | ||
{ | ||
[SerializeField] GameObject _levelPlaceholder; | ||
|
||
private ARRaycastManager _arRaycastManager; | ||
|
||
private List<RaycastHit> _raycastHits; | ||
|
||
private LevelPlacementData _levelPlacementData; | ||
|
||
private Camera _arCamera; | ||
|
||
private Pose _latestPlaneHit; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
CompatibilityChecker.AddListener(delegate (CompatibilityChecker.DeviceSupport supportedDevice) { | ||
if (supportedDevice != CompatibilityChecker.DeviceSupport.AR) { | ||
Destroy(this.gameObject); | ||
return; | ||
} | ||
|
||
this._arRaycastManager = FindObjectOfType<ARRaycastManager>(); | ||
this._arCamera = FindObjectOfType<Camera>(); | ||
this._levelPlacementData = FindObjectOfType<LevelPlacementData>(); | ||
}); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if (!SetupManager.IsSetupCompleted) return; | ||
this.LookForPlane(); | ||
this.RenderLevelPlacementPlaceholder(); | ||
this.CheckForUserInput(); | ||
} | ||
|
||
private void LookForPlane() | ||
{ | ||
Vector2 screenCenter = _arCamera.ViewportToScreenPoint(new Vector3(0.5f, 0.5f)); | ||
var hits = new List<ARRaycastHit>(); | ||
this._arRaycastManager.Raycast(screenCenter, hits, TrackableType.PlaneEstimated); | ||
|
||
if (hits.Count == 0) return; | ||
Vector3 cameraForward = _arCamera.transform.forward; | ||
Vector3 cameraBearing = new Vector3(cameraForward.x, 0, cameraForward.z); | ||
Quaternion hitRotation = Quaternion.LookRotation(cameraBearing); | ||
|
||
this._latestPlaneHit = new Pose(hits[0].pose.position, hitRotation); | ||
} | ||
|
||
private void RenderLevelPlacementPlaceholder() | ||
{ | ||
if (this._latestPlaneHit == null) return; | ||
_levelPlaceholder.transform.SetPositionAndRotation(this._latestPlaneHit.position, this._latestPlaneHit.rotation); | ||
} | ||
|
||
private void CheckForUserInput() | ||
{ | ||
if (this._latestPlaneHit == null) return; | ||
bool tappingScreenOnceWithOneFinger = Touchscreen.current.IsPressed(0); | ||
if (tappingScreenOnceWithOneFinger) | ||
{ | ||
ChoosePositionAndRotationOfLevels(_latestPlaneHit); | ||
} | ||
} | ||
|
||
private void ChoosePositionAndRotationOfLevels(Pose pose) | ||
{ | ||
_levelPlacementData.SetLevelPose(pose); | ||
Debug.Log("Level Position Set"); | ||
MoveToNextScene(); | ||
} | ||
|
||
private void MoveToNextScene() | ||
{ | ||
// TODO, create a level management system | ||
SceneManager.LoadScene("SampleScene"); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &4179574480081331153 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 4664305778208492834} | ||
- component: {fileID: 1261725758507793055} | ||
m_Layer: 0 | ||
m_Name: Level Placement Data | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 3306451490063965843, guid: 0000000000000000d000000000000000, type: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &4664305778208492834 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 4179574480081331153} | ||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_ConstrainProportionsScale: 0 | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!114 &1261725758507793055 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 4179574480081331153} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 2afa58682c2324d6192fba877a40520d, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.