Files
beyond/Assets/Scripts/UI/VideoScroll.cs
2024-11-20 15:21:28 +01:00

56 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
namespace Beyond
{
public class VideoScroll : ScrollBase
{
public VideoPlayer m_videoPlayer;
public VideoClip m_clipToPlay;
protected override void Awake()
{
base.Awake();
if (m_videoPlayer == null)
m_videoPlayer = gameObject.FindComponentDownHierarchy<VideoPlayer>();
if (m_videoPlayer != null && m_clipToPlay != null)
{
m_videoPlayer.clip = m_clipToPlay;
}
}
protected override void OnScrollOpened()
{
if (m_videoPlayer)
{
m_videoPlayer.Play();
}
}
protected override void OnScrollClosed()
{
}
// Start is called before the first frame update
protected override void Start()
{
base.Start();
OpenCloseScroll(true);
}
// Update is called once per frame
void Update()
{
if (m_videoPlayer)
{
if (m_isOpen && m_videoPlayer.frame >= (long)m_videoPlayer.frameCount-1)
{
OpenCloseScroll(false);
}
}
}
}
}