37 lines
992 B
C#
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;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|