我使用模型目标显示3d的增加。直到一切顺利每当检测到目标时,我都会使用“时间轴/可播放导演”来跟随时间轴。我的问题如下:因为我使用跟踪器设备扩展模式,所以当跟踪器模式切换到扩展跟踪器模式时会重新触发目标,因此,我希望仅在丢失跟踪时才触发目标,而不是在目标进入扩展模式跟踪器时才触发目标。如果我删除时间轴,则它变为正常,也就是说,扩展跟踪模式可以协同工作。有人帮我吗谢谢
protected override void OnTrackingFound()
{
base.OnTrackingFound();
// Play Timeline when target is found
GetComponent<PlayableDirector>().Play();
}
protected override void OnTrackingLost()
{
base.OnTrackingLost();
// Stop Timeline when target is lost
GetComponent<PlayableDirector>().Stop();
}
我猜你的脚本是基于DefaultTrackableEventHandler
的
/// <summary>
/// Implementation of the ITrackableEventHandler function called when the
/// tracking state changes.
/// </summary>
public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
OnTrackingFound();
}
else
{
OnTrackingLost();
}
}
如您所见,当跟踪在OnTrackingFound
,DETECTED
和TRACKED
之间变化时,也会调用EXTENDED_TRACKED
。>
据我所知,无需太多更改,您只需检查PlayableDirector
是否已经在播放中
// Better reference this already via the Inspector
[SerializeField] private PlayableDirector director;
private void Awake()
{
if(!director) director = GetComponent<PlayableDirector>();
}
protected override void OnTrackingFound()
{
base.OnTrackingFound();
// Play Timeline when target is found
if(director.state != PlayableState.Playing) director.Play();
}
protected override void OnTrackingLost()
{
base.OnTrackingLost();
// Stop Timeline when target is lost
directory.Stop();
}
这是DefaultTrackableEventHandler脚本中的代码
我将尝试您的建议,谢谢!