57 lines
1.2 KiB
C#
57 lines
1.2 KiB
C#
using OpenCVForUnity.VideoModule;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.Video;
|
|
|
|
public class MeditationVideoUI : UIPanelBase
|
|
{
|
|
public VideoPlayer _video;
|
|
private bool _isInit = false;
|
|
|
|
private void Awake()
|
|
{
|
|
_video = GetComponent<VideoPlayer>();
|
|
}
|
|
public override void Init(object[] pageData)
|
|
{
|
|
base.Init(pageData);
|
|
string videoPath = pageData[0] as string;
|
|
|
|
|
|
//¶¯×÷Òýµ¼½çÃæ
|
|
var video = Resources.Load<VideoClip>(videoPath);
|
|
_video.isLooping = true;
|
|
_video.playOnAwake = false;
|
|
_video.Prepare();
|
|
_video.loopPointReached += VideoEnd;
|
|
_isInit = true;
|
|
}
|
|
public override void OnEnter()
|
|
{
|
|
base.OnEnter();
|
|
_video.Play();
|
|
}
|
|
|
|
private void VideoEnd(VideoPlayer source)
|
|
{
|
|
_video.Stop();
|
|
UIManager.Instance.CloseCurrent();
|
|
LoadingManager.Instance.Load("Boot");
|
|
}
|
|
|
|
public void OnReturnBtnClicked()
|
|
{
|
|
VideoEnd(_video);
|
|
}
|
|
|
|
public override void OnExit()
|
|
{
|
|
base.OnExit();
|
|
_video.loopPointReached -= VideoEnd;
|
|
_isInit = false;
|
|
}
|
|
}
|