2025-09-10 15:15:19 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Stary.Evo.RKTools
|
|
|
|
|
|
{
|
2026-03-25 16:58:26 +08:00
|
|
|
|
#if Evo_Rokid
|
|
|
|
|
|
public class TrackedImageEvoManager : Rokid.UXR.Module.ARTrackedImageManager
|
2025-09-10 15:15:19 +08:00
|
|
|
|
{
|
2026-03-25 16:58:26 +08:00
|
|
|
|
#if ODIN_INSPECTOR
|
|
|
|
|
|
[Sirenix.OdinInspector.TableList]
|
|
|
|
|
|
#endif
|
|
|
|
|
|
public List<TarkedImageEvoData> TrackedImages;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-25 16:58:26 +08:00
|
|
|
|
|
2025-09-10 15:15:19 +08:00
|
|
|
|
Debug.LogError($"StaryEvo:未找到对应的图片的id数据,请检查是否进行前置识别 index:{imageIndex}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-25 16:58:26 +08:00
|
|
|
|
public void SetTrackedImageEvoData(int imageIndex, string domain, Transform transform)
|
2025-09-10 15:15:19 +08:00
|
|
|
|
{
|
2026-03-25 16:58:26 +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;
|
2026-03-25 16:58:26 +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
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-25 16:58:26 +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
|
|
|
|
|
|
{
|
2026-03-25 16:58:26 +08:00
|
|
|
|
#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;
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|
2026-03-25 16:58:26 +08:00
|
|
|
|
#endif
|
2025-09-10 15:15:19 +08:00
|
|
|
|
}
|