我在这个脚本中遇到了这个问题。
使用UnityEngine; 使用 Vuforia;
公共类 TouchInput_1 : MonoBehaviour, ITrackableEventHandler { 私有 TrackableBehaviour mTrackableBehaviour; 公共游戏对象 temploMaiaObject; // 引用名为“Templo_Maia”的 3D 对象 私人音频源音频源; private bool isPlaying = false;
void Start()
{
audioSource = temploMaiaObject.GetComponent<AudioSource>();
// Register this script to trackable event handler
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}
void OnDestroy()
{
// Unregister this script from trackable event handler
if (mTrackableBehaviour)
{
mTrackableBehaviour.UnregisterTrackableEventHandler(this);
}
}
public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
// Target is detected and being tracked
Debug.Log("Target is detected!");
// Enable touch input
enabled = true;
}
else
{
// Target is lost or not being tracked
Debug.Log("Target is lost!");
// Disable touch input
enabled = false;
// Pause audio playback
if (isPlaying)
{
检测到的错误
严重性代码描述项目文件行抑制状态 错误 CS0246 找不到类型或命名空间名称“ITrackableEventHandler”(是否缺少 using 指令或程序集引用?)Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 4活跃 错误 CS1513 } 预期 Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 54 活动 错误 CS1513 } 预期 Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 54 活动 错误 CS1513 } 预期 Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 54 活动 错误 CS1513 } 预期 Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 54 活动 错误 CS0246 找不到类型或命名空间名称“TrackableBehaviour”(是否缺少 using 指令或程序集引用?)Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 6活跃 错误 CS0246 找不到类型或命名空间名称“TrackableBehaviour”(是否缺少 using 指令或程序集引用?)Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 32活跃 错误 CS0246 找不到类型或命名空间名称“TrackableBehaviour”(是否缺少 using 指令或程序集引用?)Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 32活跃 错误 CS0246 找不到类型或命名空间名称“TrackableBehaviour”(是否缺少 using 指令或程序集引用?)Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 16活跃 错误 CS0103 当前上下文中不存在名称“TrackableBehaviour”Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 34 Active 错误 CS0103 当前上下文中不存在名称“TrackableBehaviour”Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 35 Active 错误 CS0103 当前上下文中不存在名称“TrackableBehaviour”Assembly-CSharp M:\IS MOTION PROJECT\PROJETO\AR\Projeto_3D\Projeto_02\Assets\TouchInput_1.cs 36 Active
我希望链接到图像目标的 3D 元素能够通过触摸屏控制播放和暂停链接到它的音频源。