Question by
phuonguyen95 · May 18, 2021 at 08:52 AM ·
buttonsvuforiaassemblygameobject.find
'GameObject' does not contain a definition for 'Find' [Assembly-CSharp]csharp(CS0117)
Hi! I am new to unity and would like to add 4 virtural buttons to move my player game object (up,down,left,right) but I am met with this problem: 'GameObject' does not contain a definition for 'Find' [Assembly-CSharp]csharp(CS0117).
Does anyone perhaps know how I can fix this? I have unity 2020.3.3f1 & my code so far looks like this. It's basically nothing
using UnityEngine; using Vuforia;
public class ButtonEventHandler : MonoBehaviour { public GameObject vbs; void Start() {
vbs = GameObject.Find("btn1"); / vbs.GetComponent().RegisterOnButtonPressed(OnButtonPressed); vbs.GetComponent().RegisterOnButtonReleased(OnButtonReleased); / }
void OnButtonPressed(VirtualButtonBehaviour vb){
switch(vb.VirtualButtonName){
case "btn1": //rechts
Debug.Log("right");
break;
case "btn2": //oben
Debug.Log("up");
break;
case "btn3": //unten
Debug.Log("down");
break;
case "btn4": //links
Debug.Log("left");
break;
}
}
void OnButtonReleased(VirtualButtonBehaviour vb){
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613033847im_/https://answers.unity.com/themes/thub/images/avi.jpg)