Hey All,
I’m trying to create a script that would be a component of a game object with a video player attached. I’ve inserted an .mp4 into the public field for the video clip, and I need some info on that clip-specifically, its length, in seconds (so that I can input that value into another script, that would destroy the video player after the clip is finished). I know that there are different ways to accomplish this. I would be interested in either making this script work, or knowing how to grab the clip length from my other script (that triggers the video player), so that it contains a precise value of time for when the video player should stop rendering. Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class VideoPlayerClipLength : MonoBehaviour
{
private int lengthy;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
lengthy = GetComponent<VideoPlayer.clip.length>();
Console.WriteLine("Clip length"+ lengthy);
}
}