Petition-to-the-Gods-V3/Assets/Scripts/Client/ClientWorkMessageResultView2SceneController.cs
2025-11-15 08:01:59 +08:00

179 lines
4.5 KiB
C#
Raw 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;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
public class ClientWorkMessageResultView2SceneController : MonoBehaviour
{
public static ClientWorkMessageResultView2SceneController Instance;
public GameObject step1Panel;
public Button step1NextButton;
public GameObject step2Panel;
public Button step2NextButton;
public Button step2ExitButton;
public GameObject step3Panel;
public Button step3NextButton;
public GameObject step4Panel;
public VideoPlayer step4VideoPlayer;
public RawImage step4RawImage;
public GameObject step5Panel;
public VideoPlayer step5VideoPlayer;
public RawImage step5RawImage;
private void Awake()
{
Instance = this;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
if (step1NextButton)
{
step1NextButton.onClick.AddListener(step1NextButton_onClicked);
}
if (step2NextButton)
{
step2NextButton.onClick.AddListener(step2NextButton_onClicked);
}
if (step2ExitButton)
{
step2ExitButton.onClick.AddListener(step2ExitButton_onClicked);
}
if (step3NextButton)
{
step3NextButton.onClick.AddListener(step3NextButton_onClicked);
}
if (step4VideoPlayer != null)
{
// ³]¸m¼v¤ùµ²§ô¨Æ¥ó
step4VideoPlayer.loopPointReached += step4VideoPlayer_onVideoFinished;
// ³]¸m¼v¤ùÅã¥Ü
if (step4RawImage != null)
{
step4VideoPlayer.targetTexture = null;
step4VideoPlayer.renderMode = VideoRenderMode.RenderTexture;
RenderTexture rt = new RenderTexture(1080, 1920, 24);
step4VideoPlayer.targetTexture = rt;
step4VideoPlayer.isLooping = false;
step4RawImage.texture = rt;
}
}
if (step5VideoPlayer != null)
{
// ³]¸m¼v¤ùµ²§ô¨Æ¥ó
step5VideoPlayer.loopPointReached += step5VideoPlayer_onVideoFinished;
// ³]¸m¼v¤ùÅã¥Ü
if (step5RawImage != null)
{
step5VideoPlayer.targetTexture = null;
step5VideoPlayer.renderMode = VideoRenderMode.RenderTexture;
RenderTexture rt = new RenderTexture(1080, 1920, 24);
step5VideoPlayer.targetTexture = rt;
step5VideoPlayer.isLooping = false;
step5RawImage.texture = rt;
}
}
processStep(1);
}
private void step5VideoPlayer_onVideoFinished(VideoPlayer source)
{
if (ClientMessageHandler.Instance)
{
ClientMessageHandler.Instance.SendMessageToServer("workProcess", "exit");
}
StartCoroutine(LoadExitScene());
}
private void step4VideoPlayer_onVideoFinished(VideoPlayer source)
{
if (ClientMessageHandler.Instance)
{
ClientMessageHandler.Instance.SendMessageToServer("workProcess", "continue");
}
}
private void step3NextButton_onClicked()
{
processStep(4);
}
private void step2ExitButton_onClicked()
{
processStep(5);
}
private void step2NextButton_onClicked()
{
processStep(3);
}
private void step1NextButton_onClicked()
{
processStep(2);
}
public void processStep(int step)
{
if (step1Panel)
{
step1Panel.SetActive(step == 1 ? true : false);
}
if (step2Panel)
{
step2Panel.SetActive(step == 2 ? true : false);
}
if (step3Panel)
{
step3Panel.SetActive(step == 3 ? true : false);
}
if (step4Panel)
{
step4Panel.SetActive(step == 4 ? true : false);
if (step == 4)
{
step4VideoPlayer.Play();
}
}
if (step5Panel)
{
step5Panel.SetActive(step == 5 ? true : false);
if (step == 5)
{
step5VideoPlayer.Play();
}
}
}
public IEnumerator LoadExitScene()
{
yield return new WaitForSeconds(0f);
SceneManager.LoadScene("ClientWorkMessageResultExitScene");
}
// Update is called once per frame
void Update()
{
}
}