Log in or register to post comments

Error in using Virtual Button

September 25, 2013 - 1:42am #1

I'm sorry for disturbing all of you,
my english is not good, i need help.

I try to create a virtual button in every object that i have been instantiated before, but there is an error.

This is The Error:

Assets/Script/manager.cs(40,58): error CS0176: Static member `ImageTargetBehaviour.CreateVirtualButton(string, UnityEngine.Vector2, UnityEngine.GameObject)' cannot be accessed with an instance reference, qualify it with a type name instead

and this is my code:

void Update () {	
		
		if (waktuCounter <= 0 && i!=1)
		{
			int ran = Random.Range(0,1);
			
			//instantiate the object
			mSemut = (GameObject)Instantiate(semut[i], posisi[ran], Quaternion.identity);
			
			//make object to child of image target
			mSemut.transform.parent = temp.transform;
			
			// Create a virtual button
			ImageTargetBehaviour itb = GetComponent<ImageTargetBehaviour>();
			VirtualButtonBehaviour vbb = itb.CreateVirtualButton(vbName[i], mSemut.transform.localPosition, mSemut);
			vbb.RegisterEventHandler(this);
			
			i++;
			//set time for loading the object
			waktuCounter = waktu;
		}		
		
		waktuCounter-= Time.deltaTime;
	}

i'm so foolish, i'm sorry. Thank's for your respond. Hope God Always Bless all of you.

Error in using Virtual Button

September 25, 2013 - 6:11am #3

i'm sorry,

but i get another error,

Could not create Virtual Button. immediateParent"immediateParent" object is not an Image Target or a child of one.
UnityEngine.Debug:LogError(Object)

i don't know why the object that i made, cannot become a child of image target and create new virtual button. if i run my program, hierarchy shows this,

but i could not find my firtual button there, my virtual button's name was ant. But it was not created successfully, and  got that error.

i change my code to be like this:

// Use this for initialization
	void Start () {		
		temp = GameObject.Find("ImageTarget");
	}
	
	// Update is called once per frame
	void Update () {	
		
		if (waktuCounter <= 0 && i!=1)
		{
			int ran = Random.Range(0,1);
			
			//instantiate the object
			mSemut = (GameObject)Instantiate(semut[i], posisi[ran], Quaternion.identity);
			
			//make object to child of image target
			mSemut.transform.parent = temp.transform;
			
			// Create a virtual button			
			VirtualButtonBehaviour vbb = ImageTargetBehaviour.CreateVirtualButton(vbName[i], mSemut.transform.localPosition, mSemut);

			vbb.RegisterEventHandler(this);
			
			i++;
			//set time for loading the object
			waktuCounter = waktu;
		}		
		
		waktuCounter-= Time.deltaTime;
	}

i'm sorry, if my english was bad,
need your help.

Error in using Virtual Button

September 25, 2013 - 2:29am #2

Hi, the API contains 2 methods to create Virtual buttons, and one of them is static, so either you use the non-static one or you use the static one with the appropriate C# syntax for statis methods;

please check the API reference:

https://developer.vuforia.com/resources/api/unity/class_image_target_behaviour

 

Log in or register to post comments