101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
namespace Stary.Evo.RKTools
|
||
{
|
||
#if Evo_Rokid
|
||
public class TrackedImageEvoManager : Rokid.UXR.Module.ARTrackedImageManager
|
||
{
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.TableList]
|
||
#endif
|
||
public List<TarkedImageEvoData> TrackedImages;
|
||
|
||
private void Start()
|
||
{
|
||
TrackedImages = new List<TarkedImageEvoData>();
|
||
}
|
||
|
||
public TarkedImageEvoData GetTrackedImageEvoData(int imageIndex)
|
||
{
|
||
foreach (var imageEvoData in TrackedImages)
|
||
{
|
||
if (imageEvoData.imageIndex == imageIndex)
|
||
{
|
||
return imageEvoData;
|
||
}
|
||
}
|
||
|
||
Debug.LogError($"StaryEvo:未找到对应的图片的id数据,请检查是否进行前置识别 index:{imageIndex}");
|
||
return null;
|
||
}
|
||
|
||
public void SetTrackedImageEvoData(int imageIndex, string domain, Transform transform)
|
||
{
|
||
bool isExit = false;
|
||
foreach (var imageEvoData in TrackedImages)
|
||
{
|
||
if (imageEvoData.imageIndex == imageIndex)
|
||
{
|
||
imageEvoData.position = transform.position;
|
||
imageEvoData.rotation = transform.eulerAngles;
|
||
imageEvoData.scale = transform.localScale;
|
||
isExit = true;
|
||
}
|
||
}
|
||
|
||
if (!isExit)
|
||
{
|
||
TrackedImages.Add(new TarkedImageEvoData()
|
||
{
|
||
imageIndex = imageIndex,
|
||
domain = domain,
|
||
position = transform.position,
|
||
rotation = transform.eulerAngles,
|
||
scale = transform.localScale
|
||
});
|
||
}
|
||
}
|
||
|
||
public TarkedImageEvoData GetTrackedImageEvoData(string domain)
|
||
{
|
||
foreach (var imageEvoData in TrackedImages)
|
||
{
|
||
if (imageEvoData.domain == domain)
|
||
{
|
||
return imageEvoData;
|
||
}
|
||
}
|
||
|
||
Debug.LogError($"StaryEvo:未找到对应的domain的id数据,请检查是否进行前置识别 domain:{domain}");
|
||
return null;
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class TarkedImageEvoData
|
||
{
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.VerticalGroup("key")]
|
||
#endif
|
||
public string domain;
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.VerticalGroup("key")]
|
||
#endif
|
||
public int imageIndex;
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.VerticalGroup("transform")]
|
||
#endif
|
||
public Vector3 position;
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.VerticalGroup("transform")]
|
||
#endif
|
||
public Vector3 rotation;
|
||
#if ODIN_INSPECTOR
|
||
[Sirenix.OdinInspector.VerticalGroup("transform")]
|
||
#endif
|
||
public Vector3 scale;
|
||
}
|
||
#endif
|
||
} |