ZhangZhouSpecialEquipment/Assets/Scripts/锅炉/GuoLuManager.cs

76 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class GuoLuManager : MonoBehaviour
{
public static GuoLuManager Instance;
[Header("所有页面")]
public GameObject[] AllPages;
private int m_curPageNum = 0;
[Header("所有视频播放器")]
public VideoPlayer[] AllVideos;
private void Awake()
{
Instance = this;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void ToOpenPage(int pageNum)
{
if (m_curPageNum != pageNum)
{
AllPages[pageNum].SetActive(true);
AllPages[m_curPageNum].SetActive(false);
m_curPageNum = pageNum;
if (m_curPageNum == 5)
{
QuizSystem.Instance.ToStartQuestion();
}
}
}
public void ToStartVideo(int videoNum)
{
AllVideos[videoNum].Play();
}
public void ToEndVideo(int videoNum)
{
AllVideos[videoNum].time = 0;
AllVideos[videoNum].Stop();
ClearRenderTexture(videoNum);
}
// 清空RenderTexture填充黑色
private void ClearRenderTexture(int num)
{
if (AllVideos[num].targetTexture == null) return;
// 保存当前激活的RenderTexture避免影响其他渲染
RenderTexture currentActiveRT = RenderTexture.active;
// 激活目标RenderTexture
RenderTexture.active = AllVideos[num].targetTexture;
// 用黑色填充0,0,0,0表示透明根据需求调整
GL.Clear(true, true, Color.black);
// 恢复之前激活的RenderTexture
RenderTexture.active = currentActiveRT;
}
}