Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPEG-SD anchoring extension #3

Merged
merged 8 commits into from
May 28, 2024
25 changes: 25 additions & 0 deletions Runtime/Scripts/ARPlacementManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 InterDigital
* Licensed under the License terms of 5GMAG software (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://www.5g-mag.com/license .
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
using GLTFast;
using UnityEngine;

public class ARPlacementManager : Singleton<ARPlacementManager>
{
// Start is called before the first frame update
public GameObject placedGameObject = null;
public GameObject placedPrefab = null;

public void ReCreatePlacement(Transform transform)
{
placedGameObject = Instantiate(placedPrefab, transform.position, transform.rotation);
placedGameObject.transform.parent = transform;
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/ARPlacementManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Runtime/Scripts/ARUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using Unity.XR.CoreUtils;
using UnityEngine;

#if !UNITY_2022_3_OR_NEWER
using UnityEngine.XR.ARFoundation;
#endif

/// <summary>
/// Utility class to handle version references
/// and a few handy methods
/// </summary>
public static class ARUtilities
{
/// <summary>
/// Returns the XR Origin or the ARSessionOrigin in the scene
/// throw an exception if it doesn't exists
/// </summary>
/// <returns></returns>
public static GameObject GetSessionOrigin()
{
// ARSessionOrigin is deprecated in version 2022.3 or above
GameObject go = null;
#if UNITY_2022_3_OR_NEWER
XROrigin or = GameObject.FindObjectOfType<XROrigin>();
if(or == null)
{
throw new Exception("No XR Origin found");
}
go = or.gameObject;
#else
ARSessionOrigin arSess = GameObject.FindObjectOfType<ARSessionOrigin>();
if(arSess == null)
{
throw new Exception("No AR Session origin found");
}
go = arSess.gameObject;
#endif
if(go == null)
{
throw new Exception("Can't initialize Trackable marker geo, no origin found");
}

return go;
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/ARUtilities.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionActivate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class ActionActivate : MonoBehaviour, IMpegInteractivityAction
private bool m_ActivationStatus;
private float m_Delay;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
m_Objects = VirtualSceneGraph.GetGameObjectsFromIndexes(action.nodes);
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class ActionAnimation : MonoBehaviour, IMpegInteractivityAction
private Animation m_PauseFrame;
private AnimationClip m_Clip;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
m_Delay = action.delay;
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class ActionBlock : MonoBehaviour, IMpegInteractivityAction
private Vector3[] m_BlockedScale;
private GameObject[] m_LockedObjects;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
m_LockedObjects = VirtualSceneGraph.GetGameObjectsFromIndexes(action.nodes);
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionManipulate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ private UnityEngine.Camera Camera
}
private UnityEngine.Camera m_Camera;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
string binding = UserInputSceneTrigger.GetBindingFromUserInputDescription(action.userInputDescription);
Expand Down
6 changes: 6 additions & 0 deletions Runtime/Scripts/ActionMedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class ActionMedia : MonoBehaviour, IMpegInteractivityAction
{
public float Delay => m_Delay;
private float m_Delay;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
m_Delay = action.delay;
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionSetAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class ActionSetAvatar : MonoBehaviour, IMpegInteractivityAction
{
public float Delay => throw new NotImplementedException();

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
throw new NotImplementedException();
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionSetHaptic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class ActionSetHaptic : MonoBehaviour, IMpegInteractivityAction
{
public float Delay => throw new NotImplementedException();

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
throw new NotImplementedException();
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionSetMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class ActionSetMaterial : MonoBehaviour, IMpegInteractivityAction
private Material m_TargetMaterial;
private float m_Delay;

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
m_Objects = VirtualSceneGraph.GetGameObjectsFromIndexes(action.nodes);
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/ActionTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class ActionTransform : MonoBehaviour, IMpegInteractivityAction
private GameObject[] m_Targets;
public float Delay => throw new NotImplementedException();

public void Dispose()
{
Destroy(gameObject);
}

public void Init(Schema.Action action)
{
// Fill the target matrix
Expand Down