Hi there.,
I have made a nice virtual button using the script I am attaching below.
This button enables a 3d model of a specific building at a specific location on my image target.
Now I want to make multiple copies of this button to activate different models at different locations on my image target, but obviously now "hardwire" the models name to the script and create ~12 different scripts for the same button.
More analytically : Top left corner of image I have to display "House", lower right of image display "Factory"
So, two questions :
a. I attach the script to the vr button in a specific location. Can it get the name of the model "above it" or will it get all model names in a scene?
b. What is the component I need? I guess Gameobject.FindObjectsofType and then get the model tag in the area?
using UnityEngine; using System.Collections; //using System.Collections.Generic; using Vuforia;
public class vbScript : MonoBehaviour, IVirtualButtonEventHandler { private GameObject VbButtonObject; private GameObject Model1; // Use this for initialization void Start () {
VbButtonObject = GameObject.Find("myVB"); Model1 = GameObject.Find ("Model1"); Model1.SetActive (false); VbButtonObject.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this); }
public void OnButtonPressed(VirtualButtonBehaviour vb) { Debug.Log ("Button Down"); Model1.SetActive (true);
}
public void OnButtonReleased(VirtualButtonBehaviour vb){
Debug.Log ("Button Up!!"); Model1.SetActive (false); } }