using GameFramework.Event; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; public class VideoManager : MonoBehaviour { public VideoManager _Instance { get; private set; } private VideoPlayer videoPlayer; private void Awake() { _Instance = this; videoPlayer = this.GetComponent(); } private void Start() { GameMain.Event.Subscribe(PlayerVideoEvent.EventId, OnDealPlayEvent); } private void OnDealPlayEvent(object sender, GameEventArgs e) { PlayerVideoEvent args = (PlayerVideoEvent)e; bool play = args.play; if (play) { var tempForm = (BaseStudyForm)sender; tempForm.SetTVFrame(videoPlayer.targetTexture); BeginPlay(); } else { StopPlay(); } } private void OnDestroy() { if (GameMain.Event.Check(PlayerVideoEvent.EventId, OnDealPlayEvent)) { GameMain.Event.Unsubscribe(PlayerVideoEvent.EventId, OnDealPlayEvent); } } public void BeginPlay() { videoPlayer.Play(); } public void StopPlay() { videoPlayer.Stop(); } }