Skip to content

Instantly share code, notes, and snippets.

@nickyeh97
Created August 19, 2024 10:21
Show Gist options
  • Save nickyeh97/ef8232268d2d62b95be64213f46bc02d to your computer and use it in GitHub Desktop.
Save nickyeh97/ef8232268d2d62b95be64213f46bc02d to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using Fungus;
/// <summary>
/// Play a video clip in the VideoPlayer.
/// </summary>
[CommandInfo("Ultrablue",
"PlayVideo",
"Play Video clip in a VideoPlayer.")]
[AddComponentMenu("")]
public class PlayVideo : Command
{
[Tooltip("Set VideoPlayer to play VideoClip")]
[SerializeField] protected VideoPlayer videoPlayer;
[Tooltip("Set VideoClip")]
[SerializeField] protected VideoClip videoClip;
public override void OnEnter()
{
if (videoPlayer != null && videoClip != null)
{
videoPlayer.clip = videoClip;
videoPlayer.Play();
}
Continue();
}
public override string GetSummary()
{
if (videoClip != null)
return "VideoName : " + videoClip.name;
else
return "Error: No video clip selected! ";
}
public override Color GetButtonColor()
{
return new Color32(150, 191, 255, 255);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment