Skip to content

Instantly share code, notes, and snippets.

@oismaelash
Last active November 11, 2017 02:00
Show Gist options
  • Save oismaelash/f0cbf1836ba366be8cf076c885c418c1 to your computer and use it in GitHub Desktop.
Save oismaelash/f0cbf1836ba366be8cf076c885c418c1 to your computer and use it in GitHub Desktop.
using Vuforia;
using UnityEngine;
using UnityEngine.Video;
public class StartVideoDynamic : MonoBehaviour, ITrackableEventHandler
{
void Start()
{
GetComponent<VideoPlayer>().enabled = false;
if (GetComponent<TrackableBehaviour>())
{
GetComponent<TrackableBehaviour>().RegisterTrackableEventHandler(this);
}
}
public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
GetComponent<VideoPlayer>().enabled = true;
GetComponent<VideoPlayer>().Play();
}
else
{
//GetComponent<VideoPlayer>().enabled = false;
GetComponent<VideoPlayer>().Pause();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment