Created
May 15, 2017 20:05
-
-
Save unity3dcollege/a55b93238076cde511862c7fb1587178 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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