Log in or register to post comments

How can i create virtualbutton at runtime?

May 23, 2014 - 4:28am #1

How can i create virtualbutton at runtime?

I need to create virtual button on gameobject at runtime because this game have 100++ gameobject.

I use this code to create virtualbutton at runtime but have some error like this

 

//monster is chlid of ImageTarget

VirtualButtonBehaviour vbb = ImageTargetBehaviour.CreateVirtualButton("button" + i.ToString(),new Vector2(2.92f, 5.44f), monster);

 

Errro :

Could not create Virtual Button.
UnityEngine.Debug:LogError(Object)
ImageTargetImpl:CreateVirtualButton(String, RectangleData) (at Assets/Qualcomm Augmented Reality/Scripts/Internal/ImageTargetImpl.cs:100)
ImageTargetBehaviour:CreateNewVirtualButtonFromBehaviour(VirtualButtonBehaviour) (at Assets/Qualcomm Augmented Reality/Scripts/ImageTargetBehaviour.cs:447)
ImageTargetBehaviour:CreateVirtualButton(String, Vector2, GameObject) (at Assets/Qualcomm Augmented Reality/Scripts/ImageTargetBehaviour.cs:180)
ControllerScript:Start() (at Assets/Script/ControllerScript.cs:40)
 

How can i create virtualbutton at runtime?

May 28, 2014 - 6:33pm #2

This Dev-Guide article about Virtual Buttons may help:

https://developer.vuforia.com/resources/dev-guide/virtual-buttons-unity

Note: In the example code, the non-static version of CreateVirtualButton() is used. The dataset which is retrieved using the GetActiveDataSets() method of the ImageTracker instance is deactivated before creating the virtual button and then reenabled afterward.

 

Log in or register to post comments