/*==============================================================================
Copyright (c) 2010-2013 QUALCOMM Austria Research Center GmbH.
All Rights Reserved.
==============================================================================*/
using UnityEngine;
using System.Collections.Generic;
///
/// This class implements the IVirtualButtonEventHandler interface and
/// contains the logic to swap materials for the teapot model depending on what
/// virtual button has been pressed.
///
public class VirtualButtonEventHandler : MonoBehaviour,
IVirtualButtonEventHandler
{
private GameObject mTeapot;
void Start()
{
// Register with the virtual buttons TrackableBehaviour
VirtualButtonBehaviour[] vbs = GetComponentsInChildren();
for (int i = 0; i < vbs.Length; ++i)
{
vbs.RegisterEventHandler(this);
}
// Get handle to the teapot object
mTeapot = transform.FindChild("teapot").gameObject;
}
#endregion // UNITY_MONOBEHAVIOUR_METHODS
#region PUBLIC_METHODS
//按下
public void OnButtonPressed(VirtualButtonBehaviour vb)
{
//Debug.Log("OnButtonPressed");
if(vb.VirtualButtonName=="button")
{
print("button name!!!");
}
if(vb.VirtualButtonName=="buttoon_text")
{
print("button_text ");
}
}
//释放
public void OnButtonReleased(VirtualButtonBehaviour vb)
{
if(vb.VirtualButtonName=="button")
{
print("button name released !!!");
}
if(vb.VirtualButtonName=="buttoon_text")
{
print("button_text released");
}
}
#endregion // PUBLIC_METHODS
}
/*==============================================================================
* Copyright (c) 2012-2013 Qualcomm Connected Experiences, Inc. All Rights Reserved.
* ==============================================================================*/
using UnityEngine;
using System.Collections.Generic;
///
/// This class implements the IVirtualButtonEventHandler interface and
/// contains the logic to swap materials for the teapot model depending on what
/// virtual button has been pressed.
///
public class VirtualButtonEventHandler : MonoBehaviour,
IVirtualButtonEventHandler
{
#region PUBLIC_MEMBER_VARIABLES
///
/// The materials that will be set for the teapot model
///
///
/// Called when the virtual button has just been pressed:
///
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
if (vb.VirtualButtonName == "Button01")
{
GameObject obj = GameObject.Find("ankylosaurus");
obj.animation.Play();
print("123456");
}
}
///
/// Called when the virtual button has just been released:
///
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
if (vb.VirtualButtonName == "Button01")
{
GameObject obj = GameObject.Find("ankylosaurus");
obj.animation.Stop();
print("wwwww");
}
}