I am very new to using Unity and I am surviving off tutorials from YouTube. As soon as my game is launched, a video is started using Video Player. I am hoping to make the video hidden after the video has finished playing to reveal my menu screen. I do have a script that I have used to hide the video player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HideVideo : MonoBehaviour
{
public GameObject VideoPlayer;
public void HideVideoPlayer()
{
VideoPlayer.gameObject.SetActive(false);
}
}
The problem is, the closest I have gotten to actually hiding my video is by setting it to an onclick event via a button. How do I make the video player hide after the video is finished playing? Thanks.
using UnityEngine;
using UnityEngine.Video;
public class intro : MonoBehaviour
{
public VideoPlayer videoPlayer;
private bool isPlayerStarted = false;
void Update()
{
if (!isPlayerStarted && videoPlayer.isPlaying)
{
isPlayerStarted = true;
}
if (isPlayerStarted && !videoPlayer.isPlaying)
{
videoPlayer.gameObject.SetActive(false);
isPlayerStarted = false;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With