46 lines
943 B
C#
46 lines
943 B
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.Video;
|
|
|
|
public class VideoMgr : MonoBehaviourSingletonTemplate<VideoMgr>
|
|
{
|
|
public VideoPlayer vp;
|
|
public GameObject go_skip;
|
|
|
|
Action act_end;
|
|
|
|
void Start()
|
|
{
|
|
vp.loopPointReached += OnVideoEnd;
|
|
}
|
|
|
|
public void PlayVideo(float skiptime, Action _end)
|
|
{
|
|
act_end = _end;
|
|
vp.gameObject.SetActive(true);
|
|
vp.Play();
|
|
|
|
StartCoroutine(Co_Run(skiptime));
|
|
}
|
|
|
|
IEnumerator Co_Run(float skiptime)
|
|
{
|
|
go_skip.SetActive(false);
|
|
yield return new WaitForSeconds(skiptime);
|
|
go_skip.SetActive(true);
|
|
}
|
|
|
|
public void OnClick_Screen()
|
|
{
|
|
if (go_skip.activeInHierarchy)
|
|
OnVideoEnd(vp);
|
|
}
|
|
|
|
private void OnVideoEnd(VideoPlayer source)
|
|
{
|
|
go_skip.SetActive(false);
|
|
vp.gameObject.SetActive(false);
|
|
act_end?.Invoke();
|
|
}
|
|
} |