【发布时间】:2021-12-14 17:11:36
【问题描述】:
我正在使用 Vuforia 在 Unity 中实现一个 AR Android 应用。我试图在检测到标记后立即播放声音,然后在未检测到标记时停止声音。当我目前在手机上构建和运行应用程序时,声音会直接播放,而我无需跟踪目标,这不是我想要的。
这是我的 C# 代码:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Vuforia;
public class Sound : DefaultTrackableEventHandler
{
protected override void OnTrackingFound()
{
base.OnTrackingFound();
AudioSource[] sounds = GetComponentsInChildren<AudioSource>();
sounds[0].Play();
}
protected override void OnTrackingLost()
{
base.OnTrackingLost();
AudioSource[] sounds = GetComponentsInChildren<AudioSource>();
sounds[0].Stop();
}
}
有人知道为什么这段代码 sn-p 不起作用吗?如果是这样,我可能会错过什么?
谢谢。
【问题讨论】:
-
可以分享控制台日志吗?
标签: c# android unity3d audio vuforia