2025-09-10 15:15:19 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Rokid.UXR.Module;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Stary.Evo.RKTools
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TrackedImageEvoManager : ARTrackedImageManager
|
|
|
|
|
|
{
|
|
|
|
|
|
[TableList] public List<TarkedImageEvoData> TrackedImages;
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2025-09-18 18:25:40 +08:00
|
|
|
|
TrackedImages = new List<TarkedImageEvoData>();
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
{
|
2025-09-18 18:25:40 +08:00
|
|
|
|
bool isExit=false;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
foreach (var imageEvoData in TrackedImages)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (imageEvoData.imageIndex == imageIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
imageEvoData.position = transform.position;
|
|
|
|
|
|
imageEvoData.rotation = transform.eulerAngles;
|
|
|
|
|
|
imageEvoData.scale = transform.localScale;
|
2025-09-18 18:25:40 +08:00
|
|
|
|
isExit=true;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-18 18:25:40 +08:00
|
|
|
|
if (!isExit)
|
2025-09-10 15:15:19 +08:00
|
|
|
|
{
|
2025-09-18 18:25:40 +08:00
|
|
|
|
TrackedImages.Add(new TarkedImageEvoData()
|
2025-09-10 15:15:19 +08:00
|
|
|
|
{
|
2025-09-18 18:25:40 +08:00
|
|
|
|
imageIndex = imageIndex,
|
|
|
|
|
|
domain = domain,
|
|
|
|
|
|
position = transform.position,
|
|
|
|
|
|
rotation = transform.eulerAngles,
|
|
|
|
|
|
scale = transform.localScale
|
|
|
|
|
|
});
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-18 18:25:40 +08:00
|
|
|
|
public TarkedImageEvoData GetTrackedImageEvoData(string domain)
|
2025-09-10 15:15:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
foreach (var imageEvoData in TrackedImages)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (imageEvoData.domain == domain)
|
|
|
|
|
|
{
|
2025-09-18 18:25:40 +08:00
|
|
|
|
return imageEvoData;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-18 18:25:40 +08:00
|
|
|
|
Debug.LogError($"StaryEvo:未找到对应的domain的id数据,请检查是否进行前置识别 domain:{domain}");
|
|
|
|
|
|
return null;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class TarkedImageEvoData
|
|
|
|
|
|
{
|
|
|
|
|
|
[VerticalGroup("key")] public string domain;
|
|
|
|
|
|
[VerticalGroup("key")] public int imageIndex;
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("transform")] public Vector3 position;
|
|
|
|
|
|
[VerticalGroup("transform")] public Vector3 rotation;
|
|
|
|
|
|
[VerticalGroup("transform")] public Vector3 scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|