Log in or register to post comments

Unity Virtual Buttons Working Example (Generic)

December 20, 2010 - 4:31am #1

It looks like the VirtualButtons scene included in SDK2 doesn't run out of the box.

It's a good exercise for Unity beginners to try making that work, but in case you don't have time, here is a working example, with all the materials hooked up, the ImageTargetEventHandler script dropped on the ImageTarget, etc.

http://uploadbox.com/files/9348cb3b07/

http://uploadbox.com/files/9348cb3b07/

Re: Unity Virtual Buttons Working Example (Generic)

May 13, 2011 - 5:44am #8

The samples aren't available in the Asset Store, you'll need to grab our installer from this site: http://ar.qualcomm.com

- Kim

Re: Unity Virtual Buttons Working Example (Generic)

May 13, 2011 - 2:59am #7

I got QCAR from unity asset store, is it possible that i don't have those examples? because i can't find them anywhere...

Re: Unity Virtual Buttons Working Example (Generic)

May 12, 2011 - 3:38pm #6

The samples are included in the Unity installer. During the installation it asks you for a folder to install the unity packages, this folder should contain these files at the end:

QCAR-1.0.0.unitypackage: the base QCAR extension
QCAR-ImageTargets-1.0.0.unitypackage: a sample project using Image Targets
QCAR-FrameMarkers-1.0.0.unitypackage: a sample project using Frame Markers
QCAR-MultiTargets-1.0.0.unitypackage: a sample project using Multi Targets
QCAR-VirtualButtons-1.0.0.unitypackage: a sample project using Virtual Buttons

For each sample unity package, simply create a new Unity project and import the package. A sample scene is included in each.

- Kim

Re: Unity Virtual Buttons Working Example (Generic)

May 12, 2011 - 3:02pm #5

My main problem is being a total newbie of unity, so i had troubles while implementing the virtual button handler interface, fixed now.
anyway, the examples aren't for regular android development only? i have no idea about how to open them in unity...

Re: Unity Virtual Buttons Working Example (Generic)

May 11, 2011 - 2:15pm #4

I don't think these would be relevant anymore with the new 1.0 release. Do you have any specific questions? I suggest looking at the VirtualButtons sample application as a good starting point.

- Kim

Re: Unity Virtual Buttons Working Example (Generic)

May 11, 2011 - 11:24am #3

example links are dead =(
do you mind re-uploading it?
thanks!

Re: Unity Virtual Buttons Working Example (Generic)

December 20, 2010 - 4:50am #2

Incidentally, here's a quick PHP snippet for converting HTML image map coordinates to Unity's VirtualButton coordinates. Replace the variables in the "malleable" section to suit with your coords. Then, put your HTML image map in $txt (surround it by q tags);


// ----- malleable -- change me!
// size of graphic in pixels
$w0=3150;
$h0=1144;

// size of imagetarget in unity
$w=267;
$h=97;
// ----- malleable -- change me!

// ratio
$r=$w0/$w;


// fetch attributes
$xml = new SimpleXMLElement($txt);
$result = $xml->xpath('/q/area');
$newtxt='';
for($j=0;$j<count($result);$j++){
    $oldcoords=$result[$j]['coords'];
    $newtemp=explode(',',$oldcoords);
    $newcoords='';
    for($i=0;$i<4;$i++){
        if($i==0||$i==2)$tempcoords=(string)((float)$newtemp[$i]/$r - $w/2);
        else if($i==1||$i==3)$tempcoords=(string)((float)$newtemp[$i]/$r + $h/2);        
        $newcoords.=round($tempcoords,2);
        $newcoords.=' ';
    }
    $newcoords=substr($newcoords,0,strlen($newcoords) - 1);
    
    $newtxt.='<VirtualButton name="'.$result[$j]['alt'].'" rectangle="'.$newcoords.'" enabled="true" />
';
}
Log in or register to post comments