Files
ZHGD_Web/Assets/Script/Tool/UMPTool.cs
2025-07-13 23:16:20 +08:00

37 lines
992 B
C#

using System.Collections;
using System.IO;
using UMP;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(UniversalMediaPlayer))]
public class UMPTool : MonoBehaviour
{
public string path;
public Text Message;
private UniversalMediaPlayer ump;
void Start()
{
Init();
}
void Init() {
ump = GetComponent<UniversalMediaPlayer>();
ump.Path = Application.streamingAssetsPath + path;
ump.AddEncounteredErrorEvent(() => {
Message.text = "当前链接失效!";
Message.color = Color.red;
ump.RenderingObjects[0].GetComponent<RawImage>().texture = Texture2D.whiteTexture;
ump.RenderingObjects[0].GetComponent<RawImage>().color = new Color(0, 0, 0, 0.5f);
});
ump.AddPlayingEvent(() =>
{
Message.text = "";
ump.RenderingObjects[0].GetComponent<RawImage>().color = Color.white;
});
}
}