赞
踩
1.右键 创建imageTarget
2.在 imageTarget下 创建一个
3.给 Quad 添加一个 Video Player
4.把 视频拖拽到 Video Player上
实现 识别到了 播放 识别丢失暂停
复制一份 Default Trackable Event Handler 里的代码
创建一个新的脚本 命名为 VideoImageTarget
将复制的 代码 粘贴到 VideoImageTarget 类里面
注意修改类名
需要添加到代码如下:
- //识别到了时
- protected virtual void OnTrackingFound()
- {
- var rendererComponents = GetComponentsInChildren<Renderer>(true);
- var colliderComponents = GetComponentsInChildren<Collider>(true);
- var canvasComponents = GetComponentsInChildren<Canvas>(true);
-
- // Enable rendering:
- foreach (var component in rendererComponents)
- component.enabled = true;
-
- // Enable colliders:
- foreach (var component in colliderComponents)
- component.enabled = true;
-
- // Enable canvas':
- foreach (var component in canvasComponents)
- component.enabled = true;
-
- //获取子物体的VideoPlayer 使视频播放
- GetComponentInChildren<VideoPlayer>().Play();
- }
-
- //识别丢失时
- protected virtual void OnTrackingLost()
- {
- var rendererComponents = GetComponentsInChildren<Renderer>(true);
- var colliderComponents = GetComponentsInChildren<Collider>(true);
- var canvasComponents = GetComponentsInChildren<Canvas>(true);
-
- // Disable rendering:
- foreach (var component in rendererComponents)
- component.enabled = false;
-
- // Disable colliders:
- foreach (var component in colliderComponents)
- component.enabled = false;
-
- // Disable canvas':
- foreach (var component in canvasComponents)
- component.enabled = false;
- //获取子物体的VideoPlayer 使视频暂停
- GetComponentInChildren<VideoPlayer>().Pause();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。