Unity 收藏本版 已有9人收藏 +发表新主题
查看: 23541|回复: 0
打印 上一主题 下一主题

[分享] unity基础开发----高通 AR Unity 虚拟按钮

[复制链接]

[分享] unity基础开发----高通 AR Unity 虚拟按钮

xiancai 发表于 2016-4-23 10:47:54 浏览:  23541 回复:  0 只看该作者 复制链接
高通开发AR都想用到互动,虚拟按钮互动可以实现虚拟和现实的结合互动。
我使用的版本是vuforia-sampleapps-unity-2-5-8的,具体怎么得到这个看http://blog.csdn.net/liang_704959721/article/details/9201765
主要代码

/*==============================================================================  Copyright (c) 2010-2013 QUALCOMM Austria Research Center GmbH.  All Rights Reserved.  ==============================================================================*/    using UnityEngine;  using System.Collections.Generic;    /// <summary>  /// 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.  /// </summary>  public class VirtualButtonEventHandler : MonoBehaviour,                                           IVirtualButtonEventHandler  {        private GameObject mTeapot;      void Start()      {          // Register with the virtual buttons TrackableBehaviour          VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();          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  }
添加到这个物体上ImageTarget,在添加
注意 virtual Button Behaviour 这个脚本的name就是vb.VirtualButtonName=="button";
这样就ok了

wenwen5

打算发大水发圣达菲阿斯蒂芬发大水
分享至:
| 1 人收藏
回复

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

新手上路

Copyright © 2013-2017 ARinChina-增强现实中国技术论坛   All Rights Reserved.