using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
//虚拟按钮的接口
public class ButtonManager : MonoBehaviour, IVirtualButtonEventHandler
{
//要旋转或者放大的物体
public Transform cube;
//虚拟按钮组件
VirtualButtonBehaviour[] buttons;
private void Awake()
{
buttons = GetComponentsInChildren<VirtualButtonBehaviour>();
for (int i = 0; i < buttons.Length; i++)
{
//注册当前代码
buttons[i].RegisterEventHandler(this);
}
}
//判断 点击按钮的名字
public void OnButtonPressed(VirtualButtonBehaviour vb)
{
switch (vb.VirtualButtonName)
{
case "Left":
cube.transform.localEulerAngles += new Vector3(23, 42, 31);
break;
case "Right":
cube.transform.localScale += new Vector3(0.2f, 0.2f, 0.2f);
break;
}
}
public void OnButtonReleased(VirtualButtonBehaviour vb)
{
}
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}