- Home /
 
Creating 2 Virtual Button in 1 scene
hi! I want to ask how to make 2 virtual buttons at once? I'm really confused about the "(variable name).GetComponent().RegisterOnButtonPressed(OnButtonPressed);" because I want to make 2 vb. this is my code, please correct me if something is wrong, pls help me because i'm a unity beginner thank you.
using System.Collections; using System.Collections.Generic; using UnityEngine; using Vuforia;
public class VBManager : MonoBehaviour {
 // private fields to store models
 private GameObject sc_brosur;
 private GameObject sc_video;
 private GameObject btn_1;
 private GameObject btn_2;
 // memanggil scene ketika loaded
 void Start() {
     // mencari child dari object ini yang memiliki script VirtualButtonBehaviour
     btn_1 = GameObject.Find("btn_info");
     btn_2 = GameObject.Find("btn_video");
    btn_1.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonPressed(OnButtonPressed);
    btn_1.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonReleased(OnButtonReleased);
    btn_2.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonPressed(OnButtonPressed);
    btn_2.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonReleased(OnButtonReleased);
     // setelah tracking camera model bisa muncul ketika ditekan
     sc_brosur.SetActive(false);
     sc_video.SetActive(false);
     btn_1.SetActive(true); //vb brosur
     btn_2.SetActive(true); //vb video
     
 }
 /// <summary>
 // memanggil objek ketika virtual button ditekan (eksekusi)
 /// </summary>
 public void OnButtonPressed(VirtualButtonBehaviour vb) {
     Debug.Log("Button pressed!");
     switch(vb.VirtualButtonName) {
         case "btn_info":
         btn_1.SetActive(true);
         btn_2.SetActive(true);
         sc_video.SetActive(false);
         sc_brosur.SetActive(true);
                 break;
         case "btn_video":
         btn_1.SetActive(true);
         btn_2.SetActive(false);
         sc_video.SetActive(true);
         sc_brosur.SetActive(false);
                 break;
     }
 }
 public void OnButtonReleased(VirtualButtonBehaviour vb) {
     Debug.Log("Button released!");
 }
 
               }
hii can anyone give me a solution? I'm so confused, pls help me. thank you
Your answer
 
             Follow this Question
Related Questions
How to lock object when get tracking 0 Answers
How to measure the distance between an Augmented Reality marker and camera? 0 Answers
Button to disable image target identification and frame marker 0 Answers
How to have a placement marker on ground plane in AR Core ? 0 Answers
Cloud recognition in Vuforia 0 Answers