using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; public class CourseEffectBgManager : MonoBehaviour { //影片组 [SerializeField] private VideoClip[] clips; //荧幕 [SerializeField] private EffectScreen eScreen; void Start() { MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间 MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间 //MessageCenter.Instance.Register(GameEnum.MESSAGE_SHOW_COURSE, ShowEffect);//显示房间 //MessageCenter.Instance.Register(GameEnum.MESSAGE_HIDE_COURSE, HideEffect);//隐藏房间 HideEffect(); } private void OnDestroy() { MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间 MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间 //MessageCenter.Instance.UnRegister(GameEnum.MESSAGE_SHOW_COURSE, ShowEffect);//显示房间 //MessageCenter.Instance.UnRegister(GameEnum.MESSAGE_HIDE_COURSE, HideEffect);//隐藏房间 } private void ShowEffect(System.Object data = null) { if (GamePlayerData.Instance.room_data != null && GamePlayerData.Instance.room_data.CurOnlineData.subject_id <= clips.Length) { CDebug.Log("subject_id " + GamePlayerData.Instance.room_data.CurOnlineData.subject_id); eScreen.ChangeMoive(clips[GamePlayerData.Instance.room_data.CurOnlineData.subject_id - 1]); } } private void HideEffect(System.Object data = null) { eScreen.ChangeMoive(null); } // Update is called once per frame void Update() { if(Input.GetKeyDown(KeyCode.P)) { ChangeMovie(); } } //换片 private void ChangeMovie() { eScreen.ChangeMoive(clips[Random.Range(0, clips.Length)]); } }