mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-21 22:58:50 -05:00
Figured out how to use the qr code to position/rotate the course using the ObjectSpawner script
This commit is contained in:
parent
1f64320da5
commit
89a212c66c
24
Assets/Atoms/Variables/TrackedImageManagerEnabled.asset
Normal file
24
Assets/Atoms/Variables/TrackedImageManagerEnabled.asset
Normal file
@ -0,0 +1,24 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 593b70f10d7bb41c78d42c7e8b6609da, type: 3}
|
||||
m_Name: TrackedImageManagerEnabled
|
||||
m_EditorClassIdentifier:
|
||||
_developerDescription:
|
||||
_id:
|
||||
_value: 0
|
||||
_changed: {fileID: 0}
|
||||
_changedWithHistory: {fileID: 0}
|
||||
_triggerChangedOnOnEnable: 0
|
||||
_triggerChangedWithHistoryOnOnEnable: 0
|
||||
_oldValue: 0
|
||||
_initialValue: 1
|
||||
_preChangeTransformers: []
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4a6ccb6b3f244b0ca8da90699997ce5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,131 +0,0 @@
|
||||
// NOTE: Taken from https://github.com/dilmerv/UnityARFoundationEssentials/blob/master/Assets/Scripts/TrackedImageInfoMultipleManager.cs
|
||||
// This has been modified to fit the need of the UDRI XRTeam's use-cases
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Logging;
|
||||
using Unity.Mathematics;
|
||||
using UnityAtoms.BaseAtoms;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
|
||||
namespace MAVRIC.GEEEKCup.Samples.QRCode
|
||||
{
|
||||
public class TrackedImageChanged : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private LogLevel logLevel = LogLevel.Warning;
|
||||
|
||||
[SerializeField] private ARTrackedImageManager trackedImageManager;
|
||||
[SerializeField] private GameObjectReference parentObject;
|
||||
[SerializeField] private GameObject[] arPrefabs;
|
||||
|
||||
[SerializeField] private float3 scaleFactor = new (0.1f, 0.1f, 0.1f);
|
||||
|
||||
private Dictionary<string, GameObject> arObjects = new ();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (trackedImageManager == null)
|
||||
{
|
||||
if (!TryGetComponent(out trackedImageManager))
|
||||
{
|
||||
Log.Error("Failed to find ARTrackedImageManager...", this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentObject?.Value == null)
|
||||
{
|
||||
parentObject.Value = gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (trackedImageManager == null) return;
|
||||
|
||||
trackedImageManager.trackedImagesChanged += OnTrackedImagesChanged;
|
||||
|
||||
SpawnAllARObjects();
|
||||
}
|
||||
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (trackedImageManager == null) return;
|
||||
|
||||
trackedImageManager.trackedImagesChanged -= OnTrackedImagesChanged;
|
||||
|
||||
for (int i = arObjects.Keys.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var key = arObjects.Keys.ElementAt(i);
|
||||
if (arObjects.Remove(key, out var value))
|
||||
{
|
||||
Destroy(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnAllARObjects()
|
||||
{
|
||||
// setup all game objects in dictionary
|
||||
foreach (GameObject arObject in arPrefabs)
|
||||
{
|
||||
GameObject newARObject = Instantiate(arObject, Vector3.zero, Quaternion.identity);
|
||||
newARObject.transform.SetParent(parentObject.Value.transform);
|
||||
newARObject.SetActive(false);
|
||||
|
||||
newARObject.name = arObject.name;
|
||||
arObjects.Add(arObject.name, newARObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs)
|
||||
{
|
||||
foreach (ARTrackedImage trackedImage in eventArgs.added)
|
||||
{
|
||||
UpdateARImage(trackedImage);
|
||||
}
|
||||
|
||||
foreach (ARTrackedImage trackedImage in eventArgs.updated)
|
||||
{
|
||||
UpdateARImage(trackedImage);
|
||||
}
|
||||
|
||||
foreach (ARTrackedImage trackedImage in eventArgs.removed)
|
||||
{
|
||||
arObjects[trackedImage.name].SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateARImage(ARTrackedImage trackedImage)
|
||||
{
|
||||
// Assign and Place Game Object
|
||||
AssignGameObject(trackedImage.referenceImage.name, trackedImage.transform.position, scaleFactor, trackedImage.transform.rotation);
|
||||
|
||||
Log.Verbose("trackedImage.referenceImage.name: {0}", trackedImage.referenceImage.name);
|
||||
}
|
||||
|
||||
private void AssignGameObject(string name, Vector3 newPosition, Vector3 newScale, Quaternion newRotation)
|
||||
{
|
||||
if (arPrefabs != null)
|
||||
{
|
||||
GameObject goARObject = arObjects[name];
|
||||
goARObject.transform.SetParent(parentObject.Value.transform);
|
||||
goARObject.SetActive(true);
|
||||
|
||||
goARObject.transform.position = newPosition;
|
||||
goARObject.transform.localScale = newScale;
|
||||
goARObject.transform.localRotation = newRotation;
|
||||
|
||||
foreach (GameObject go in arObjects.Values)
|
||||
{
|
||||
Log.Verbose("Go in arObjects.Values: {0}", go.name);
|
||||
if (go.name != name)
|
||||
{
|
||||
go.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -29,13 +29,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512387469002778309}
|
||||
serializedVersion: 2
|
||||
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: 2512387470890420967}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &2512387469002778331
|
||||
Camera:
|
||||
@ -51,9 +51,17 @@ Camera:
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
@ -222,9 +230,20 @@ MonoBehaviour:
|
||||
m_Dithering: 0
|
||||
m_ClearDepth: 1
|
||||
m_AllowXRRendering: 1
|
||||
m_AllowHDROutput: 1
|
||||
m_UseScreenCoordOverride: 0
|
||||
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
quality: 3
|
||||
frameInfluence: 0.1
|
||||
jitterScale: 1
|
||||
mipBias: 0
|
||||
varianceClampScale: 0.9
|
||||
contrastAdaptiveSharpening: 0
|
||||
--- !u!1 &2512387470528047719
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -238,6 +257,7 @@ GameObject:
|
||||
- component: {fileID: 2512387470528047736}
|
||||
- component: {fileID: 2512387470528047737}
|
||||
- component: {fileID: 2512387470528047718}
|
||||
- component: {fileID: 8976608592028004041}
|
||||
m_Layer: 0
|
||||
m_Name: XR Origin (AR Rig)
|
||||
m_TagString: Untagged
|
||||
@ -252,6 +272,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512387470528047719}
|
||||
serializedVersion: 2
|
||||
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}
|
||||
@ -259,7 +280,6 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 2512387470890420967}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2512387470528047739
|
||||
MonoBehaviour:
|
||||
@ -276,8 +296,8 @@ MonoBehaviour:
|
||||
m_Camera: {fileID: 2512387469002778331}
|
||||
m_OriginBaseGameObject: {fileID: 2512387470528047719}
|
||||
m_CameraFloorOffsetObject: {fileID: 2512387470890420964}
|
||||
m_RequestedTrackingOriginMode: 1
|
||||
m_CameraYOffset: 0
|
||||
m_RequestedTrackingOriginMode: 0
|
||||
m_CameraYOffset: 1.1176
|
||||
--- !u!114 &2512387470528047736
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -306,7 +326,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_PlanePrefab: {fileID: 1585201990951412, guid: a6b7ca1d53c75490595d1f0d5f43be38,
|
||||
type: 3}
|
||||
m_DetectionMode: -1
|
||||
m_DetectionMode: 1
|
||||
--- !u!114 &2512387470528047718
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -320,6 +340,22 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RaycastPrefab: {fileID: 0}
|
||||
--- !u!114 &8976608592028004041
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512387470528047719}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4dea56a9eaadd1c439095de4f9a371cb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SerializedLibrary: {fileID: 11400000, guid: 566278178fcf04566b14f73c97cab6ff,
|
||||
type: 2}
|
||||
m_MaxNumberOfMovingImages: 1
|
||||
m_TrackedImagePrefab: {fileID: 0}
|
||||
--- !u!1 &2512387470890420964
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -343,21 +379,22 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512387470890420964}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalPosition: {x: 0, y: 1.1176, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 2512387469002778308}
|
||||
- {fileID: 2512387470319625118}
|
||||
m_Father: {fileID: 2512387470528047738}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &8752705094176965077
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 2512387470890420967}
|
||||
m_Modifications:
|
||||
- target: {fileID: 6605111590819766853, guid: 069266f272f67eb43b7e9423a4e669d2,
|
||||
@ -426,6 +463,9 @@ PrefabInstance:
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 069266f272f67eb43b7e9423a4e669d2, type: 3}
|
||||
--- !u!4 &2512387470319625118 stripped
|
||||
Transform:
|
||||
|
@ -233,5 +233,44 @@ namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets
|
||||
objectSpawned?.Invoke(newObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TrySpawnObject(Vector3 spawnPoint, Quaternion spawnRotation, Space space)
|
||||
{
|
||||
if (m_OnlySpawnInView)
|
||||
{
|
||||
var inViewMin = m_ViewportPeriphery;
|
||||
var inViewMax = 1f - m_ViewportPeriphery;
|
||||
var pointInViewportSpace = cameraToFace.WorldToViewportPoint(spawnPoint);
|
||||
if (pointInViewportSpace.z < 0f || pointInViewportSpace.x > inViewMax || pointInViewportSpace.x < inViewMin ||
|
||||
pointInViewportSpace.y > inViewMax || pointInViewportSpace.y < inViewMin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var objectIndex = isSpawnOptionRandomized ? Random.Range(0, m_ObjectPrefabs.Count) : m_SpawnOptionIndex;
|
||||
var newObject = Instantiate(m_ObjectPrefabs[objectIndex]);
|
||||
|
||||
if (m_SpawnAsChildren || space == Space.Self)
|
||||
{
|
||||
newObject.transform.parent = transform;
|
||||
newObject.transform.localPosition = spawnPoint;
|
||||
newObject.transform.localRotation = spawnRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
newObject.transform.position = spawnPoint;
|
||||
newObject.transform.rotation = spawnRotation;
|
||||
}
|
||||
|
||||
if (m_ApplyRandomAngleAtSpawn)
|
||||
{
|
||||
var randomRotation = Random.Range(-m_SpawnAngleRange, m_SpawnAngleRange);
|
||||
newObject.transform.Rotate(Vector3.up, randomRotation);
|
||||
}
|
||||
|
||||
objectSpawned?.Invoke(newObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.18028326, g: 0.22571333, b: 0.30692202, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.18028373, g: 0.22571398, b: 0.30692294, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@ -123,6 +123,52 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &80173837
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 80173839}
|
||||
- component: {fileID: 80173838}
|
||||
m_Layer: 0
|
||||
m_Name: XR Interaction Manager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &80173838
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 80173837}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 83e4e6cca11330d4088d729ab4fc9d9f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_StartingHoverFilters: []
|
||||
m_StartingSelectFilters: []
|
||||
--- !u!4 &80173839
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 80173837}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.40358174, y: 1.0660288, z: 0.73515534}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &331264285
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -146,46 +192,6 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: XR Origin (AR Rig)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
@ -203,7 +209,11 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 573055497}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 48cb3fb68c91eb94999fd99957eb0cae, type: 3}
|
||||
--- !u!4 &331264286 stripped
|
||||
@ -230,6 +240,7 @@ GameObject:
|
||||
- component: {fileID: 436358033}
|
||||
- component: {fileID: 436358035}
|
||||
- component: {fileID: 436358036}
|
||||
- component: {fileID: 436358037}
|
||||
m_Layer: 0
|
||||
m_Name: Object Spawner
|
||||
m_TagString: Untagged
|
||||
@ -258,9 +269,9 @@ MonoBehaviour:
|
||||
m_SpawnOptionIndex: 0
|
||||
m_OnlySpawnInView: 1
|
||||
m_ViewportPeriphery: 0
|
||||
m_ApplyRandomAngleAtSpawn: 1
|
||||
m_ApplyRandomAngleAtSpawn: 0
|
||||
m_SpawnAngleRange: 45
|
||||
m_SpawnAsChildren: 0
|
||||
m_SpawnAsChildren: 1
|
||||
--- !u!4 &436358034
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -283,7 +294,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 436358032}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ba63293f961b46a1a5b648e4ba02cfb5, type: 3}
|
||||
m_Name:
|
||||
@ -319,6 +330,96 @@ MonoBehaviour:
|
||||
spawnedObjects: []
|
||||
objectLimit: 1
|
||||
objectSpawner: {fileID: 436358033}
|
||||
--- !u!114 &436358037
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 436358032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2178f015d10c24dc7a75d7f4ad028733, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
trackedImageManager: {fileID: 1077107346}
|
||||
objectSpawner: {fileID: 436358033}
|
||||
trackedImageManagerEnabled:
|
||||
_usage: 2
|
||||
_value: 0
|
||||
_constant: {fileID: 0}
|
||||
_variable: {fileID: 11400000, guid: a4a6ccb6b3f244b0ca8da90699997ce5, type: 2}
|
||||
_variableInstancer: {fileID: 0}
|
||||
--- !u!1 &573055496
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 573055497}
|
||||
- component: {fileID: 573055498}
|
||||
m_Layer: 0
|
||||
m_Name: Listeners
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &573055497
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 573055496}
|
||||
serializedVersion: 2
|
||||
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: 1077107342}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &573055498
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 573055496}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9a6ab7cbc45164d19b20476265c251c2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_developerDescription:
|
||||
_unityEventResponse:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1077107346}
|
||||
m_TargetAssemblyTypeName: UnityEngine.Behaviour, UnityEngine
|
||||
m_MethodName: set_enabled
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
_actionResponses: []
|
||||
_conditions: []
|
||||
_operator: 0
|
||||
_replayEventBufferOnRegister: 1
|
||||
_eventReference:
|
||||
_usage: 2
|
||||
_event: {fileID: 0}
|
||||
_eventInstancer: {fileID: 0}
|
||||
_variable: {fileID: 11400000, guid: a4a6ccb6b3f244b0ca8da90699997ce5, type: 2}
|
||||
_variableInstancer: {fileID: 0}
|
||||
--- !u!1 &702413256
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -509,6 +610,24 @@ MonoBehaviour:
|
||||
m_LightCookieSize: {x: 1, y: 1}
|
||||
m_LightCookieOffset: {x: 0, y: 0}
|
||||
m_SoftShadowQuality: 0
|
||||
--- !u!4 &1077107342 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2512387470528047738, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 331264285}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1077107346 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8976608592028004041, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 331264285}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4dea56a9eaadd1c439095de4f9a371cb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1323550131
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -604,6 +723,30 @@ MonoBehaviour:
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
--- !u!1 &1345703127 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2515407931999965833, guid: 3ccc2f7c888da2b4c9997752a4d80cc2,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 7183032743472781730}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1345703131
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1345703127}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 87d2015568c3a4fdbbc02c30ac8c1a14, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
reference:
|
||||
_usage: 2
|
||||
_value: 0
|
||||
_constant: {fileID: 0}
|
||||
_variable: {fileID: 11400000, guid: a4a6ccb6b3f244b0ca8da90699997ce5, type: 2}
|
||||
_variableInstancer: {fileID: 0}
|
||||
--- !u!114 &1366176488 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 2512387470319625105, guid: 48cb3fb68c91eb94999fd99957eb0cae,
|
||||
@ -1453,7 +1596,11 @@ PrefabInstance:
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 2515407931999965833, guid: 3ccc2f7c888da2b4c9997752a4d80cc2,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1345703131}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 3ccc2f7c888da2b4c9997752a4d80cc2, type: 3}
|
||||
--- !u!1001 &9054095629342217002
|
||||
PrefabInstance:
|
||||
@ -1539,3 +1686,4 @@ SceneRoots:
|
||||
- {fileID: 7183032743472781730}
|
||||
- {fileID: 1323550134}
|
||||
- {fileID: 9054095629342217002}
|
||||
- {fileID: 80173839}
|
||||
|
96
Assets/Scripts/AR/TrackedImageChanged.cs
Normal file
96
Assets/Scripts/AR/TrackedImageChanged.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using Unity.Logging;
|
||||
using UnityAtoms.BaseAtoms;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
|
||||
namespace MAVRIC.GEEKCup
|
||||
{
|
||||
using ObjectSpawner = UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets.ObjectSpawner;
|
||||
|
||||
public class TrackedImageChanged : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ARTrackedImageManager trackedImageManager;
|
||||
[SerializeField] private ObjectSpawner objectSpawner;
|
||||
[SerializeField] private BoolReference trackedImageManagerEnabled;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (trackedImageManager == null)
|
||||
{
|
||||
if (!TryGetComponent(out trackedImageManager))
|
||||
{
|
||||
Log.Error("Failed to find ARTrackedImageManager...", this.gameObject);
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (objectSpawner == null)
|
||||
{
|
||||
if (!TryGetComponent(out objectSpawner))
|
||||
{
|
||||
Log.Error("Failed to find ObjectSpawner...", this.gameObject);
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
trackedImageManager.trackedImagesChanged += OnTrackedImagesChanged;
|
||||
|
||||
objectSpawner.objectSpawned += UpdateObjectSpawned;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
trackedImageManager.trackedImagesChanged -= OnTrackedImagesChanged;
|
||||
|
||||
objectSpawner.objectSpawned -= UpdateObjectSpawned;
|
||||
}
|
||||
|
||||
private void UpdateObjectSpawned(GameObject obj)
|
||||
{
|
||||
if (obj == null) return;
|
||||
|
||||
var position = obj.transform.localPosition;
|
||||
|
||||
position.y = 0f;
|
||||
obj.transform.localPosition = position;
|
||||
}
|
||||
|
||||
private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs obj)
|
||||
{
|
||||
foreach (var trackedImage in obj.added)
|
||||
{
|
||||
if (AttachTrackedImage(trackedImage))
|
||||
{
|
||||
OneShot();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var trackedImage in obj.updated)
|
||||
{
|
||||
if (AttachTrackedImage(trackedImage))
|
||||
{
|
||||
OneShot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool AttachTrackedImage(ARTrackedImage trackedImage)
|
||||
{
|
||||
if (trackedImage == null) return false;
|
||||
if (objectSpawner == null) return false;
|
||||
|
||||
var position = trackedImage.transform.position;
|
||||
var rotation = trackedImage.transform.rotation;
|
||||
|
||||
return objectSpawner.TrySpawnObject(position, rotation, Space.Self);
|
||||
}
|
||||
|
||||
private void OneShot()
|
||||
{
|
||||
trackedImageManager.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecb22d2c87e61499cbc8fdc37392f22e
|
||||
guid: 2178f015d10c24dc7a75d7f4ad028733
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
8
Assets/Scripts/Atoms.meta
Normal file
8
Assets/Scripts/Atoms.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19be4f5a67e194087892d0e3a183195c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/Scripts/Atoms/BoolReferenceSetter.cs
Normal file
23
Assets/Scripts/Atoms/BoolReferenceSetter.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityAtoms.BaseAtoms;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MAVRIC.GEEKCup.Atoms
|
||||
{
|
||||
public class BoolReferenceSetter : MonoBehaviour
|
||||
{
|
||||
public BoolReference reference;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
reference.Value = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
reference.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Atoms/BoolReferenceSetter.cs.meta
Normal file
11
Assets/Scripts/Atoms/BoolReferenceSetter.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87d2015568c3a4fdbbc02c30ac8c1a14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -140,7 +140,11 @@ PlayerSettings:
|
||||
visionOSBundleVersion: 1.0
|
||||
tvOSBundleVersion: 1.0
|
||||
bundleVersion: 1.0.0
|
||||
preloadedAssets: []
|
||||
preloadedAssets:
|
||||
- {fileID: 8792172334962700932, guid: 3fd4fc0127790db4bae83f7b77da8d45, type: 2}
|
||||
- {fileID: 11400000, guid: c199e683398494f32b4cde18e73ab731, type: 2}
|
||||
- {fileID: 4800000, guid: e7c77f6eaab324a819efdc13b8125a39, type: 3}
|
||||
- {fileID: 4800000, guid: 6743a50a812740be8c0aa3fccc46fae9, type: 3}
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
m_HolographicPauseOnTrackingLoss: 1
|
||||
|
Loading…
Reference in New Issue
Block a user