Vuforia开发高阶二-虚拟按钮(第二部分)
来源:互联网 发布:分布式数据库 hadoop 编辑:程序博客网 时间:2024/06/05 20:46
public class MyVirtualButtonControl : MonoBehaviour,IVirtualButtonEventHandler{ #region PUBLIC_MEMBER_VARIABLES public ImageTargetBehaviour imageTargetBehaviour; public AudioSource button_audio; /// <summary> /// The materials that will be set for the teapot model /// </summary> //public Material[] m_TeapotMaterials; #endregion // PUBLIC_MEMBER_VARIABLES #region PRIVATE_MEMBER_VARIABLES private GameObject mTeapot; private List<Material> mActiveMaterials; #endregion // PRIVATE_MEMBER_VARIABLES private Vector2 top; private Vector2 bottom; public GameObject myObject; private string labelname = "Hello,ANTVR!"; #region UNITY_MONOBEHAVIOUR_METHODS void Start() { // Register with the virtual buttons TrackableBehaviour VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>(); for (int i = 0; i < vbs.Length; ++i) { vbs<i>.RegisterEventHandler(this); vbs<i>.CalculateButtonArea(out top,out bottom); Debug.Log("----->"+vbs.Length); //vbs<i>.VirtualButton.Name+ Debug.Log("---->"+top.x+":"+top.y+"----->"+bottom.x+":"+bottom.y); } VirtualButtonBehaviour vb= (VirtualButtonBehaviour)imageTargetBehaviour.CreateVirtualButton ("eleven",new Vector2(-10,10),new Vector2(10,-10)); if (vb != null) { vb.VirtualButton.SetEnabled(true); Debug.Log("!!!!!!!!!"+vb.VirtualButton.Name); } // Get handle to the teapot object //mTeapot = transform.FindChild("teapot").gameObject; // The list of active materials mActiveMaterials = new List<Material>(); } #endregion // UNITY_MONOBEHAVIOUR_METHODS #region PUBLIC_METHODS /// <summary> /// Called when the virtual button has just been pressed: /// </summary> public void OnButtonPressed(VirtualButtonAbstractBehaviour vb) { if (!button_audio.isPlaying) { button_audio.Play(); } if (button_audio.isPlaying) { button_audio.volume=1; } Debug.Log("OnButtonPressed::" + vb.VirtualButtonName); // Add the material corresponding to this virtual button // to the active material list: switch (vb.VirtualButtonName) { case "one": //myObject.transform.animation.Play(); myObject.transform.animation.Play("Take 4"); labelname = "one -> Run!"; if (!button_audio.isPlaying) { button_audio.Play(); } if (button_audio.isPlaying) { button_audio.volume=1; } break; case "two": myObject.transform.animation.Play("Take 002"); labelname = "two -> Nothing!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "three": //myObject.transform.animation.Play("Take 4"); myObject.transform.animation.Play(); labelname = "three -> Stand!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "four": myObject.transform.animation.Play("Take 5"); labelname = "four -> Hello!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "five": //myObject.transform.animation.Play("Take 5"); myObject.transform.animation.Play(); labelname = "five -> Stand!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "six": myObject.transform.animation.Play("Take 5"); labelname = "six -> Hello!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "seven": //myObject.transform.animation.Play("Take 5"); myObject.transform.animation.Play("Take 4"); labelname = "seven -> Stand!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "eight": myObject.transform.animation.Play("Take 002"); labelname = "eight -> Hello!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "nine": //myObject.transform.animation.Play("Take 5"); myObject.transform.animation.Play("Take 4"); labelname = "nine -> Stand!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "ten": myObject.transform.animation.Play("Take 002"); labelname = "ten -> Hello!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; case "eleven": myObject.transform.animation.Play("Take 002"); labelname = "eleven -> Hello!"; if (!button_audio.isPlaying) { button_audio.Play(); } break; } } /// <summary> /// Called when the virtual button has just been released: /// </summary> public void OnButtonReleased(VirtualButtonAbstractBehaviour vb) { // Remove the material corresponding to this virtual button // from the active material list: switch (vb.VirtualButtonName) { case "one": break; case "two": break; case "three": break; case "four": break; } } #endregion // PUBLIC_METHODS void OnGUI(){ GUI.Label (new Rect (10, 10, 100, 100), labelname); }}</i></i></i>
0 0
- Vuforia开发高阶二-虚拟按钮(第二部分)
- Vuforia开发高阶二-虚拟按钮(第二部分)
- Vuforia开发高阶二-虚拟按钮(第一部分)
- Vuforia开发高阶二-虚拟按钮(第一部分)
- Vuforia开发高阶二-虚拟按钮(第三部分)
- Vuforia开发高阶二-虚拟按钮(第四部分)
- (Unity3d)Vuforia开发高阶二-虚拟按钮
- Unity + vuforia 开发虚拟按钮
- Vuforia开发高阶三-用户自定义Target(第二部分)
- Vuforia虚拟按钮
- Vuforia开发技巧一-提高Target的识别率(第二部分)
- Vuforia Virtual Button(虚拟按钮)使用技巧
- Vuforia开发高阶三-用户自定义Target(第一部分)
- 10.高通 Vuforia for Unity 虚拟按钮 (包教会教程,学不会你砍我)
- Vuforia开发技巧一-提高Target的识别率(第一部分)
- Vuforia Virtual Button(虚拟按钮)案例一——按钮位置计算
- Vuforia Virtual Button(虚拟按钮)案例二——按钮事件处理
- Vuforia Virtual Button(虚拟按钮)案例一——按钮位置计算
- HTTP协议状态码详解(HTTP Status Code)
- Spring加载properties文件的两种方式
- 黑马程序员:C/C++学习路线图已上线!一图在手,天下我有!
- iOS 跳转到地图App后的各种操作
- WebView的简单使用
- Vuforia开发高阶二-虚拟按钮(第二部分)
- html表格标签使用
- 二维树状数组
- hexo+github搭建博客
- [Extjs6]清除数组内容
- 教你如何在Android 6.0上创建系统悬浮窗
- (Unity3d)Vuforia开发高阶二-虚拟按钮
- 去除桌面的svn问号标志符
- IOS 疯狂基础之 页面间跳转