I’ve been trying to learn how to make different kinds of UI elements. I’m currently trying to get a basic video player to work. I have several short video clips that I can trigger. I want to make it so that when one clip is finished, the next one is played automatically. I used the built-in Event system on the UI Elements to make things work so far, but now I figure I need my manager script to check with the Video Player component if the Event LoopPointReached has been triggered.
I’m using Unity’s built-in Video Player component, not an inherited class (did I say that right?).
So what I have going is basically this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class SimpleManager : MonoBehaviour
{
/*
The array lists the video clips that are in the playlist.
The index shows which location is currently being played.
vidPlay is a reference to the GameObject holding the Video Player component.
*/
public VideoClip[] video;
public int index = 0;
public GameObject vidPlay;
void Start ()
{
vidPlay.GetComponent<VideoPlayer>().LoopPointReached += IncrementVideo();
}
//The array listing the videos has an index number of 12.
public void IncrementVideo()
{
if (index != 11)
{
HandleInputData(index + 1);
}
else
{
PressedPlay();
}
}
//HandleInputData sets the clip in [int] postion to play.
// PressedPlay is called when the last video has played to move the user back to the video select screen.
This does, for reasons I don’t even faintly understand, not work. The error message is " ‘VideoPlayer’ does not contain a definition for ‘LoopPointReached’ and no accessible extension method ‘LoopPointReached’ accepting a first argument of type ‘VideoPlayer’ could be found (are you missing a using directive or an assembly reference?)". I’m guessing this means that I’m doing something wrong when I try to subscribe to the event?
I am extrapolating this on the code that is here in the documentation (event subscription and methid call at the end of code example).
Is anyone able to point me to a resource or something that can help me understand why this code does not run as intended?
I have tried searching the forums a bit, but I can’t seem to find threads who’s solotion I have been able to implement.