1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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<VideoPlayer>();
- }
- 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();
- }
- }
|