i have a invertedsphere with my 360 degreevideo on it and when the video end it should change the scene but my brain isnt strong enough to handle this simple problem pls help.
here my both scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.Playables;
public class startthevideomyprecious : MonoBehaviour {
//Raw Image to Show Video Images [Assign from the Editor]
//public RawImage image;
//Video To Play [Assign from the Editor]
public VideoClip videoToPlay;
private VideoPlayer videoPlayer;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
// Use this for initialization
void Start()
{
Application.runInBackground = true;
StartCoroutine(playVideo());
}
IEnumerator playVideo()
{
//Add VideoPlayer to the GameObject
videoPlayer = gameObject.AddComponent<VideoPlayer> ();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource> ();
//Disable Play on Awake for both Video and Audio
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = false;
//We want to play from video clip not from url
videoPlayer.source = VideoSource.VideoClip;
//Set video To Play then prepare Audio to prevent Buffering
videoPlayer.clip = videoToPlay;
videoPlayer.Prepare ();
//Wait until video is prepared
while (!videoPlayer.isPrepared) {
Debug.Log ("Preparing Video");
yield return null;
}
Debug.Log ("Done Preparing Video");
//Set Audio Output to AudioSource
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
videoPlayer.EnableAudioTrack (0, true);
videoPlayer.SetTargetAudioSource (0, audioSource);
//Assign the Texture from Video to RawImage to be displayed
//image.texture = videoPlayer.texture;
//Play Video
videoPlayer.Play ();
//Play Sound
audioSource.Play ();
}
}
i tried to get a message when the video ends but nothing happend
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class loadsceneaftercideomiagy : MonoBehaviour {
private VideoPlayer videoPlayer;
// Use this for initialization
// Update is called once per frame
void Update () {
videoPlayer = gameObject.AddComponent<VideoPlayer> ();
if (VideoPlayer.loopPointReached) {
Debug.Log ("video end");
}
}
}