当前位置:   article > 正文

Unity_AR_Vuforia实现识别图视频播放_unityar扫描图片出现动画

unityar扫描图片出现动画

1.右键 创建imageTarget

2.在 imageTarget下 创建一个

3.给 Quad 添加一个 Video Player 

4.把 视频拖拽到 Video Player上

实现 识别到了 播放   识别丢失暂停

复制一份 Default Trackable Event Handler 里的代码

创建一个新的脚本 命名为 VideoImageTarget

将复制的 代码 粘贴到 VideoImageTarget 类里面

注意修改类名

需要添加到代码如下:

  1. //识别到了时
  2. protected virtual void OnTrackingFound()
  3. {
  4. var rendererComponents = GetComponentsInChildren<Renderer>(true);
  5. var colliderComponents = GetComponentsInChildren<Collider>(true);
  6. var canvasComponents = GetComponentsInChildren<Canvas>(true);
  7. // Enable rendering:
  8. foreach (var component in rendererComponents)
  9. component.enabled = true;
  10. // Enable colliders:
  11. foreach (var component in colliderComponents)
  12. component.enabled = true;
  13. // Enable canvas':
  14. foreach (var component in canvasComponents)
  15. component.enabled = true;
  16. //获取子物体的VideoPlayer 使视频播放
  17. GetComponentInChildren<VideoPlayer>().Play();
  18. }
  19. //识别丢失时
  20. protected virtual void OnTrackingLost()
  21. {
  22. var rendererComponents = GetComponentsInChildren<Renderer>(true);
  23. var colliderComponents = GetComponentsInChildren<Collider>(true);
  24. var canvasComponents = GetComponentsInChildren<Canvas>(true);
  25. // Disable rendering:
  26. foreach (var component in rendererComponents)
  27. component.enabled = false;
  28. // Disable colliders:
  29. foreach (var component in colliderComponents)
  30. component.enabled = false;
  31. // Disable canvas':
  32. foreach (var component in canvasComponents)
  33. component.enabled = false;
  34. //获取子物体的VideoPlayer 使视频暂停
  35. GetComponentInChildren<VideoPlayer>().Pause();
  36. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/626396
推荐阅读
相关标签
  

闽ICP备14008679号