Vuforia--VirtualButton的使用
来源:互联网 发布:java 值传递 引用传递 编辑:程序博客网 时间:2024/05/17 08:42
一,在官网上创建Key和Target就不说了,将创建的Imarget资源包导入Unity中,设置 Key 值,勾选激活程序集,设置图片Type 跟ImageTarget案例一样
二,将prefab ARCamera 和 ImageTarget拖入Hierarchy中 并将VirtualButton拖入ImageTarget作为子物体 修改名字为Button1
三,在Button1上 将Name属性改为Button1
四,在ImageTarget上的基本如图
四,其中可对VirtualButtonEventHandler修改 实现效果(也可以自己创建一个脚本)
using UnityEngine;using System.Collections.Generic;using Vuforia;public class VirtualButtonEventHandler : MonoBehaviour, IVirtualButtonEventHandler{ public Material m_VirtualButtonMaterial; public Transform cube; void Start() { // Register with the virtual buttons TrackableBehaviour and set the material VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>(); for (int i = 0; i < vbs.Length; ++i) { vbs[i].RegisterEventHandler(this); if (m_VirtualButtonMaterial != null) { vbs[i].GetComponent<MeshRenderer>().sharedMaterial = m_VirtualButtonMaterial; } } } //当按钮按下时 public void OnButtonPressed(VirtualButtonAbstractBehaviour vb) { cube.GetComponent<Renderer>().material.color = Color.red; print(vb.VirtualButtonName); } //当按钮释放时 public void OnButtonReleased(VirtualButtonAbstractBehaviour vb) { cube.GetComponent<Renderer>().material.color = Color.blue; print(vb.VirtualButtonName); }}
阅读全文
0 0
- Vuforia--VirtualButton的使用
- AR/VR learning (3)--虚拟按键(virtualButton)的测试与使用
- unity ~ vuforia的入门使用
- Vuforia一-VideoPlayback的使用
- Vuforia的学习(三) Vuforia ARCamer的使用
- Vuforia——VuMark 的使用
- Vuforia Object Scanner 使用
- 基于vuforia的图像识别Jar的使用
- 基于vuforia的图像识别Jar的使用
- Vuforia的学习(五)ImageTarget的使用
- 关于VideoPlayer以及使用VUforia播放视频的见解
- 【Vuforia】Vuforia实现自动对焦的代码
- Vuforia.
- Vuforia AR SDK使用入门
- Hololens入门之使用Vuforia
- HoloLens开发笔记-使用Vuforia
- Unity如何深入使用Vuforia
- Vuforia的学习(一)---Vuforia的介绍
- C++之操作符重载
- 产生随机数的Random类的框架
- 蝉
- scandir() has been disabled for security reasons
- 使用PostgreSql心得
- Vuforia--VirtualButton的使用
- java发送手机验证码
- sqlserver 表被哪个过程引用
- Perl脚本中Expect模块的学习使用
- 通俗、有逻辑的写一篇说下Xgboost的原理,供讨论参考
- 输入相应类型的字符串并显示
- ArangoDB AQL中的图形绘制遍历
- Application.mk的文件梳理
- 学习SpringMVC