Skip to content

Instantly share code, notes, and snippets.

@oismaelash
Created March 12, 2018 12:03
Show Gist options
  • Save oismaelash/e0a37dad1f193ad4a26f1d0eeb0fee83 to your computer and use it in GitHub Desktop.
Save oismaelash/e0a37dad1f193ad4a26f1d0eeb0fee83 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using UnityEngine.Video;
public class VirtualButtonManager : MonoBehaviour, IVirtualButtonEventHandler
{
[SerializeField] private UnityEngine.UI.Image imagePanel;
[SerializeField] private VideoPlayer videoPlayer;
void Start ()
{
imagePanel.color = Color.green;
GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);
}
public void OnButtonPressed(VirtualButtonBehaviour vb) //Quando a mão está sobre o botão virtual
{
WhenIsPress();
}
public void OnButtonReleased(VirtualButtonBehaviour vb) //Quando vc retira a sua mão do botão virtual
{
WhenIsReleased();
}
private void WhenIsPress()
{
imagePanel.color = Color.blue;
PlayOrPauseVideo();
print("WhenIsPress");
}
private void WhenIsReleased()
{
imagePanel.color = Color.green;
print("WhenIsReleased");
}
private void PlayOrPauseVideo()
{
if (!videoPlayer.isPlaying);
videoPlayer.Play();
else
videoPlayer.Pause();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment