Last active
November 11, 2017 02:00
-
-
Save oismaelash/f0cbf1836ba366be8cf076c885c418c1 to your computer and use it in GitHub Desktop.
This file contains 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 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