Ошибка компиляции в синтаксисе VirtualButtonBehaviour - PullRequest
0 голосов
/ 31 декабря 2018

Я создаю небольшое приложение, использующее движки 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 []"

1 Ответ

0 голосов
/ 27 августа 2019

VirtualButtonBehaviour [] vrb = GetComponentInChildren ();

Вы должны изменить GetComponentInChildren Использовать GetComponentsInChildren

...