【发布时间】:2018-12-31 16:40:05
【问题描述】:
我正在使用 Unity/Vuforia 引擎创建一个小应用程序,当我循环访问虚拟按钮时,我收到以下编译错误。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class XYZScript : MonoBehaviour,IVirtualButtonEventHandler {
public GameObject xgo, ygo;
// Start is called before the first frame update
void Start()
{
VirtualButtonBehaviour[] vrb = GetComponentInChildren<VirtualButtonBehaviour>();
for(int i=0; i<vrb.Length; i++)
{
vrb[i].RegisterEventHandler(this);
}
xgo.SetActive(false);
ygo.SetActive(false);
}
我收到了错误
VirtualButtonBehaviour[] vrb = GetComponentInChildren<VirtualButtonBehaviour>();
错误信息:
此行为将虚拟按钮与游戏对象相关联。使用 ImageTargetBehavior 中的功能在运行时创建和销毁虚拟按钮。
不能隐含隐蔽类型“Vuforia.VirtualButtonBehaviour”到 "Vuforia.VirtualButtonBehaviour[]"
【问题讨论】:
-
第二个是错字,你可能想使用
GetComponentsInChildren(注意s)。 (提示:您可能还想将true作为 orser 中的参数传递给它,以获取残疾儿童的组件。)我认为第一条错误消息是不言自明的...... -
@derHugo 非常感谢!效果很好!!
标签: c# unity3d vuforia vuforia-cloud-recognition