1
0
mirror of https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git synced 2025-01-22 07:08:51 -05:00

TrackedImages: Sample scene for multiple tracked images

This commit is contained in:
cbrown 2024-04-17 10:11:13 -04:00
parent 6b34f941fb
commit 37c11b88b2
12 changed files with 1367 additions and 146 deletions

View File

@ -562,11 +562,11 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_CameraStartingPose: m_CameraStartingPose:
position: {x: 0.22, y: 0.9345944, z: -0.21} position: {x: 0, y: 1.1176, z: 0}
rotation: {x: -0.16794881, y: 0.414527, z: -0.078137435, w: -0.8909855} rotation: {x: 0, y: 0, z: 0, w: 1}
m_CameraMovementBounds: m_CameraMovementBounds:
m_Center: {x: 0.044999838, y: 0.545, z: 0.00000011920929} m_Center: {x: 0.044999838, y: 0.545, z: 0.00000011920929}
m_Extent: {x: 1.3000004, y: 0.5500002, z: 1.2500005} m_Extent: {x: 1.3000004, y: 1, z: 1.2500005}
m_DefaultViewPose: m_DefaultViewPose:
position: {x: 0, y: 1.0609863, z: -1.5} position: {x: 0, y: 1.0609863, z: -1.5}
rotation: {x: -0.16100603, y: 0.1567927, z: -0.025916385, w: -0.97407466} rotation: {x: -0.16100603, y: 0.1567927, z: -0.025916385, w: -0.97407466}

View File

@ -23,19 +23,17 @@ MonoBehaviour:
m_SerializedTextureGuid: m_SerializedTextureGuid:
m_GuidLow: 9512191862091720473 m_GuidLow: 9512191862091720473
m_GuidHigh: 4777916657343582074 m_GuidHigh: 4777916657343582074
m_Size: {x: 0, y: 0} m_Size: {x: 0.1, y: 0.1}
m_SpecifySize: 0 m_SpecifySize: 1
m_Name: qr-code-01 m_Name: qr-code-01
m_Texture: {fileID: 6192944022281365145, guid: cf56a719181984027acf62a7e2914e42, m_Texture: {fileID: 0}
type: 3}
- m_SerializedGuid: - m_SerializedGuid:
m_GuidLow: 5000005727017362315 m_GuidLow: 5000005727017362315
m_GuidHigh: 17579163435370083502 m_GuidHigh: 17579163435370083502
m_SerializedTextureGuid: m_SerializedTextureGuid:
m_GuidLow: 8415066286968600214 m_GuidLow: 8415066286968600214
m_GuidHigh: 355843442228713881 m_GuidHigh: 355843442228713881
m_Size: {x: 0, y: 0} m_Size: {x: 0.1, y: 0.1}
m_SpecifySize: 0 m_SpecifySize: 1
m_Name: qr-code-02 m_Name: qr-code-02
m_Texture: {fileID: 6192944022281365145, guid: fc20f696523374c899d9b1b1b935f004, m_Texture: {fileID: 0}
type: 3}

View File

@ -30,7 +30,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 1119266294257528679} m_Father: {fileID: 1119266294257528679}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -131,11 +131,12 @@ Transform:
m_GameObject: {fileID: 7740556873076377330} m_GameObject: {fileID: 7740556873076377330}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.939, y: 0, z: 2.135} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: m_Children:
- {fileID: 6463251211347540605} - {fileID: 6463251211347540605}
- {fileID: 1629418972370686959}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2974374142263200146 --- !u!114 &2974374142263200146
@ -151,3 +152,97 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_DestroyOnRemoval: 1 m_DestroyOnRemoval: 1
--- !u!1001 &1231279924666610692
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1119266294257528679}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.x
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.y
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.z
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.50008726
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.49991274
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.50008726
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.z
value: 0.49991274
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -89.98
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_Name
value: 3D RightArrow
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c8389a6832c69794daffd97728da0cb9, type: 3}
--- !u!4 &1629418972370686959 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
m_PrefabInstance: {fileID: 1231279924666610692}
m_PrefabAsset: {fileID: 0}

View File

@ -26,11 +26,12 @@ Transform:
m_GameObject: {fileID: 2334735618901841031} m_GameObject: {fileID: 2334735618901841031}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.939, y: 0, z: 2.135} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 507655295618772503} - {fileID: 507655295618772503}
- {fileID: 7610384848938991257}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6628545826349043593 --- !u!114 &6628545826349043593
@ -75,7 +76,7 @@ Transform:
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 7368655793651849036} m_Father: {fileID: 7368655793651849036}
@ -151,3 +152,97 @@ SphereCollider:
serializedVersion: 3 serializedVersion: 3
m_Radius: 0.5 m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 0, z: 0}
--- !u!1001 &7932877230784944498
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 7368655793651849036}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.x
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.y
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalScale.z
value: 35
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.50008726
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.49991274
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.50008726
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalRotation.z
value: 0.49991274
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -89.98
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
propertyPath: m_Name
value: 3D RightArrow
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c8389a6832c69794daffd97728da0cb9, type: 3}
--- !u!4 &7610384848938991257 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: c8389a6832c69794daffd97728da0cb9,
type: 3}
m_PrefabInstance: {fileID: 7932877230784944498}
m_PrefabAsset: {fileID: 0}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e0e8618ff31454360ad62f1a57d5ff5c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
// NOTE: This is copied Unity Technologies' AR Foundation Samples project from GitHub (https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/Runtime/XROriginExtensions.cs)
// The code may be modified to fit the need of the UDRI XRTeam's use-cases
using System;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
// MODIFICATION: Namespace changed to fit within UDRI XRT's package namespace conventions
namespace MAVRIC.XR.ARFoundation.Extensions
{
/// <summary>
/// This class contains extension methods suitable for replacing the <c>ARSessionOrigin.MakeContentAppearAt</c>
/// API as existed in AR Foundation 4.2, allowing users to upgrade projects from
/// <see cref="ARSessionOrigin"/> to <see cref="XROrigin"/> with continued access to this API.
/// </summary>
public static class XROriginExtensions
{
/// <summary>
/// Makes <paramref name="content"/> appear to be placed at <paramref name="position"/> with orientation <paramref name="rotation"/>.
/// </summary>
/// <param name="origin">The <c>XROrigin</c> in the Scene.</param>
/// <param name="content">The <c>Transform</c> of the content you wish to affect.</param>
/// <param name="position">The position you wish the content to appear at. This could be
/// a position on a detected plane, for example.</param>
/// <param name="rotation">The rotation the content should appear to be in, relative
/// to the <c>Camera</c>.</param>
/// <remarks>
/// This method does not actually change the <c>Transform</c> of content; instead,
/// it updates the <c>XROrigin</c>'s <c>Transform</c> so the content
/// appears to be at the given position and rotation. This is useful for placing AR
/// content onto surfaces when the content itself cannot be moved at runtime.
/// For example, if your content includes terrain or a NavMesh, it cannot
/// be moved or rotated dynamically.
/// </remarks>
public static void MakeContentAppearAt(this XROrigin origin, Transform content, Vector3 position, Quaternion rotation)
{
MakeContentAppearAt(origin, content, position);
MakeContentAppearAt(origin, content, rotation);
}
/// <summary>
/// Makes <paramref name="content"/> appear to be placed at <paramref name="position"/>.
/// </summary>
/// <param name="origin">The <c>XROrigin</c> in the Scene.</param>
/// <param name="content">The <c>Transform</c> of the content you wish to affect.</param>
/// <param name="position">The position you wish the content to appear at. This could be
/// a position on a detected plane, for example.</param>
/// <remarks>
/// This method does not actually change the <c>Transform</c> of content; instead,
/// it updates the <c>XROrigin</c>'s <c>Transform</c> so the content
/// appears to be at the given position.
/// </remarks>
public static void MakeContentAppearAt(this XROrigin origin, Transform content, Vector3 position)
{
if (content == null)
throw new ArgumentNullException(nameof(content));
var originTransform = origin.transform;
// Adjust the Camera Offset transform to account
// for the actual position we want the content to appear at.
origin.CameraFloorOffsetObject.transform.position += originTransform.position - position;
// The XROrigin's position needs to match the content's pivot. This is so
// the entire XROrigin rotates around the content (so the impression is that
// the content is rotating, not the rig).
originTransform.position = content.position;
}
/// <summary>
/// Makes <paramref name="content"/> appear to have orientation <paramref name="rotation"/> relative to the <c>Camera</c>.
/// </summary>
/// <param name="origin">The <c>XROrigin</c> in the Scene.</param>
/// <param name="content">The <c>Transform</c> of the content you wish to affect.</param>
/// <param name="rotation">The rotation the content should appear to be in, relative
/// to the <c>Camera</c>.</param>
/// <remarks>
/// This method does not actually change the <c>Transform</c> of content; instead,
/// it updates the <c>XROrigin</c>'s <c>Transform</c> so that the content
/// appears to be in the requested orientation.
/// </remarks>
public static void MakeContentAppearAt(this XROrigin origin, Transform content, Quaternion rotation)
{
if (content == null)
throw new ArgumentNullException(nameof(content));
// Since we aren't rotating the content, we need to perform the inverse
// operation on the XROrigin. For example, if we want the
// content to appear to be rotated 90 degrees on the Y axis, we should
// rotate our rig -90 degrees on the Y axis.
origin.transform.rotation = Quaternion.Inverse(rotation) * content.rotation;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a513f970b04541f288e351b19ab10ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,124 +1,119 @@
using System.Collections.Generic; // NOTE: Taken from https://github.com/dilmerv/UnityARFoundationEssentials/blob/master/Assets/Scripts/TrackedImageInfoMultipleManager.cs
using UnityEngine; // This has been modified to fit the need of the UDRI XRTeam's use-cases
using UnityEngine.InputSystem;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
namespace AR using System.Collections.Generic;
using System.Linq;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
namespace MAVRIC.GEEKCup.AR
{ {
public class TrackedImageChanged : MonoBehaviour public class TrackedImageChanged : MonoBehaviour
{ {
[SerializeField] ARTrackedImageManager m_TrackedImageManager; [SerializeField] private ARTrackedImageManager trackedImageManager;
[SerializeField] private GameObject[] arPrefabs;
[SerializeField] private List<ARTrackedImage> _arTrackedImagePrefabs = new (); [SerializeField] private float3 scaleFactor = new (0.1f, 0.1f, 0.1f);
private List<ARTrackedImage> _spawned = new ();
#if UNITY_EDITOR private Dictionary<string, GameObject> arObjects = new ();
[Header("Debug")]
[SerializeField] private InputAction m_DebugListImages;
#endif
void OnEnable() private void Awake()
{ {
m_TrackedImageManager.trackedImagesChanged += OnChange; if (trackedImageManager == null)
{
if (!TryGetComponent(out trackedImageManager))
{
Debug.LogError("Failed to find ARTrackedImageManager");
}
}
}
private void OnEnable()
{
if (trackedImageManager == null) return;
#if UNITY_EDITOR trackedImageManager.trackedImagesChanged += OnTrackedImagesChanged;
m_DebugListImages.Enable();
m_DebugListImages.performed += Debug_ListImages;
#endif
}
void OnDisable()
{
m_TrackedImageManager.trackedImagesChanged -= OnChange;
#if UNITY_EDITOR SpawnAllARObjects();
m_DebugListImages.performed -= Debug_ListImages;
m_DebugListImages.Disable();
#endif
} }
private void OnChange(ARTrackedImagesChangedEventArgs eventArgs)
private void OnDisable()
{ {
foreach (var newImage in eventArgs.added) if (trackedImageManager == null) return;
trackedImageManager.trackedImagesChanged -= OnTrackedImagesChanged;
for (int i = arObjects.Keys.Count - 1; i >= 0; i--)
{ {
// Handle added event var key = arObjects.Keys.ElementAt(i);
Debug.Log($"Added image: {newImage.referenceImage.name}"); if (arObjects.Remove(key, out var value))
foreach (var prefab in _arTrackedImagePrefabs)
{ {
if (prefab.referenceImage.name.Equals(newImage.referenceImage.name)) Destroy(value);
{
if (_spawned == null)
{
_spawned = new List<ARTrackedImage>();
}
// Spawn new object
Debug.Log("Spawning object...");
_spawned.Add(Instantiate(prefab, newImage.transform));
}
}
}
foreach (var updatedImage in eventArgs.updated)
{
// Handle updated event
Debug.Log($"Updated image: {updatedImage.trackableId} - {updatedImage.trackingState}");
foreach (var spawnedObject in _spawned)
{
if (spawnedObject.trackableId == updatedImage.trackableId)
{
// Update position
Debug.Log("Updating position...");
spawnedObject.transform.position = updatedImage.transform.position;
}
}
}
foreach (var removedImage in eventArgs.removed)
{
// Handle removed event
Debug.Log($"Removed image: {removedImage.referenceImage.name}");
for (int i = _spawned.Count - 1; i >= 0; i--)
{
var spawnedObject = _spawned[i];
if (spawnedObject.trackableId == removedImage.trackableId)
{
// Handle object removal
Debug.Log("Removing object...");
if (_spawned.Remove(spawnedObject))
{
// Destroy object
Debug.Log("Destroying object...");
Destroy(spawnedObject.gameObject);
}
}
} }
} }
} }
private void ListAllImages() private void SpawnAllARObjects()
{ {
Debug.Log( // setup all game objects in dictionary
$"There are {m_TrackedImageManager.trackables.count} images being tracked."); foreach (GameObject arObject in arPrefabs)
foreach (var trackedImage in m_TrackedImageManager.trackables)
{ {
Debug.Log($"Image: {trackedImage.referenceImage.name} is at " + GameObject newARObject = Instantiate(arObject, Vector3.zero, Quaternion.identity);
$"{trackedImage.transform.position}"); newARObject.SetActive(false);
newARObject.name = arObject.name;
arObjects.Add(arObject.name, newARObject);
} }
} }
private ARTrackedImage GetImageAt(TrackableId trackableId) private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs)
{ {
return m_TrackedImageManager.trackables[trackableId]; 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 Debug_ListImages(InputAction.CallbackContext _) => ListAllImages(); private void UpdateARImage(ARTrackedImage trackedImage)
{
// Assign and Place Game Object
AssignGameObject(trackedImage.referenceImage.name, trackedImage.transform.position, scaleFactor, trackedImage.transform.rotation);
Debug.Log($"trackedImage.referenceImage.name: {trackedImage.referenceImage.name}");
}
private void AssignGameObject(string name, Vector3 newPosition, Vector3 newScale, Quaternion newRotation)
{
if (arPrefabs != null)
{
GameObject goARObject = arObjects[name];
goARObject.SetActive(true);
goARObject.transform.position = newPosition;
goARObject.transform.localScale = newScale;
goARObject.transform.localRotation = newRotation;
foreach (GameObject go in arObjects.Values)
{
Debug.Log($"Go in arObjects.Values: {go.name}");
if (go.name != name)
{
go.SetActive(false);
}
}
}
}
} }
} }

View File

@ -0,0 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
namespace MAVRIC.GEEKCup
{
public class TransformTracker : MonoBehaviour
{
public Transform target;
public TMP_Text output;
private void Awake()
{
if (target == null)
{
target = transform;
}
}
private void Update()
{
output.text = JsonUtility.ToJson(target.position, true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e36d5b65f0ec847c8aaa6bd34616f053
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,33 +3,45 @@
--- !u!159 &1 --- !u!159 &1
EditorSettings: EditorSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 9 serializedVersion: 12
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2 m_SerializationMode: 2
m_LineEndingsForNewScripts: 2 m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 0 m_DefaultBehaviorMode: 0
m_PrefabRegularEnvironment: {fileID: 0} m_PrefabRegularEnvironment: {fileID: 0}
m_PrefabUIEnvironment: {fileID: 0} m_PrefabUIEnvironment: {fileID: 0}
m_SpritePackerMode: 0 m_SpritePackerMode: 0
m_SpritePackerCacheSize: 10
m_SpritePackerPaddingPower: 1 m_SpritePackerPaddingPower: 1
m_Bc7TextureCompressor: 0
m_EtcTextureCompressorBehavior: 1 m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1 m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2 m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4 m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp
m_ProjectGenerationRootNamespace: m_ProjectGenerationRootNamespace: MAVRIC.GEEKCup
m_CollabEditorSettings:
inProgressEnabled: 1
m_EnableTextureStreamingInEditMode: 1 m_EnableTextureStreamingInEditMode: 1
m_EnableTextureStreamingInPlayMode: 1 m_EnableTextureStreamingInPlayMode: 1
m_EnableEditorAsyncCPUTextureLoading: 0
m_AsyncShaderCompilation: 1 m_AsyncShaderCompilation: 1
m_PrefabModeAllowAutoSave: 1
m_EnterPlayModeOptionsEnabled: 0 m_EnterPlayModeOptionsEnabled: 0
m_EnterPlayModeOptions: 3 m_EnterPlayModeOptions: 3
m_ShowLightmapResolutionOverlay: 1 m_GameObjectNamingDigits: 1
m_GameObjectNamingScheme: 0
m_AssetNamingUsesSpace: 1
m_InspectorUseIMGUIDefaultInspector: 0
m_UseLegacyProbeSampleCount: 0 m_UseLegacyProbeSampleCount: 0
m_SerializeInlineMappingsOnOneLine: 0
m_DisableCookiesInLightmapper: 1
m_AssetPipelineMode: 1 m_AssetPipelineMode: 1
m_RefreshImportMode: 0
m_CacheServerMode: 0 m_CacheServerMode: 0
m_CacheServerEndpoint: m_CacheServerEndpoint:
m_CacheServerNamespacePrefix: default m_CacheServerNamespacePrefix: default
m_CacheServerEnableDownload: 1 m_CacheServerEnableDownload: 1
m_CacheServerEnableUpload: 1 m_CacheServerEnableUpload: 1
m_CacheServerEnableAuth: 0
m_CacheServerEnableTls: 0
m_CacheServerValidationMode: 2
m_CacheServerDownloadBatchSize: 128
m_EnableEnlightenBakedGI: 0