12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Video;
- using System;
- public class VideoControl : MonoBehaviour {
- public GameObject Icon;
- public Material material;
- bool? isStart = true;
- public VideoPlayer videoPlayer;
- public string VideoURL;
- [Serializable]
- public class VideoInfo {
- public VideoClip video;
- public int index;
- }
- public List<VideoInfo> videoList;
- public void VideoStartSwitch() {
- isStart = videoPlayer.isPlaying;
- isStart = !isStart;
- Icon.SetActive(!isStart.Value);
- if(videoPlayer.url !=VideoURL)
- videoPlayer.url = VideoURL;
- if (isStart.Value) {
- videoPlayer?.Play();
- } else {
- videoPlayer?.Pause();
- }
- }
- public void PlayVideo(int index) {
- if(videoPlayer == null)
- return;
-
- foreach (var item in videoList) {
- if(item.index == index) {
- videoPlayer.clip = item.video;
- videoPlayer?.Play();
- Icon.SetActive(false);
- break;
- }
- }
- }
- }
|