1.插入3D面板当做视频播放的载体,再更换材质为ImageTarget中对应的照片,再添加视频组件,指定视频文件
2.在Plane下添加UI世界级窗口,再添加按钮控制视频播放
3.代码
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; public class AudioMP4 : MonoBehaviour { public VideoPlayer video; public Button button; //播放 public void OnPlayer() { if (!video.isPlaying) { video.Play(); //隐藏按钮 button.gameObject.SetActive(false); } } //停止 public void OnPause() { if (video.isPlaying) { video.Pause(); //显示按钮 button.gameObject.SetActive(true); } } //按键控制播放或者暂停 private void updata() { if (Input.GetKeyDown(KeyCode.Space)) { if (video.isPlaying) { video.Pause(); //显示按钮 button.gameObject.SetActive(true); } else { video.Play(); //隐藏按钮 button.gameObject.SetActive(false); } } } }
标签:button,Vuforia,video,按钮,using,播放,public,Unity2021 From: https://www.cnblogs.com/clf125800/p/17215436.html