首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VirtualButtonBehaviour语法中的编译错误

VirtualButtonBehaviour语法中的编译错误
EN

Stack Overflow用户
提问于 2018-12-31 16:40:05
回答 1查看 189关注 0票数 0

我正在创建一个小型应用程序,使用统一/Vuforia引擎,当我循环使用虚拟按钮时,我会得到下面的编译错误。

代码语言:javascript
复制
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);        
    }

我收到的错误是

代码语言:javascript
复制
VirtualButtonBehaviour[] vrb = GetComponentInChildren<VirtualButtonBehaviour>();

错误信息:

此行为将虚拟按钮与游戏对象关联。使用ImageTargetBehavior中的功能在运行时创建和销毁虚拟按钮. 不能将隐蔽类型"Vuforia.VirtualButtonBehaviour“表示为"Vuforia.VirtualButtonBehaviour[]”

EN

回答 1

Stack Overflow用户

发布于 2019-08-26 21:13:20

VirtualButtonBehaviour[] vrb = GetComponentInChildren();

必须更改使用GetComponentsInChildren的GetComponentInChildren

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53989576

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档