我正在创建一个小型应用程序,使用统一/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[]”
发布于 2019-08-26 21:13:20
VirtualButtonBehaviour[] vrb = GetComponentInChildren();
必须更改使用GetComponentsInChildren的GetComponentInChildren
https://stackoverflow.com/questions/53989576
复制相似问题