Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created May 15, 2017 20:05
Show Gist options
  • Select an option

  • Save unity3dcollege/a55b93238076cde511862c7fb1587178 to your computer and use it in GitHub Desktop.

Select an option

Save unity3dcollege/a55b93238076cde511862c7fb1587178 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Video;
public class VideoSelection : MonoBehaviour
{
[SerializeField]
private VideoClip videoClip;
private VideoPlayer videoPlayer;
private void Start()
{
videoPlayer = FindObjectOfType<VideoPlayer>();
}
private void OnTriggerEnter(Collider collider)
{
StartClipIfNotAlreadyPlaying();
}
public void StartClipIfNotAlreadyPlaying()
{
if (videoPlayer.clip != videoClip)
{
videoPlayer.clip = videoClip;
videoPlayer.Play();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment