MedaiPlayerSampleGUI.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. using System.Collections;
  3. public class MedaiPlayerSampleGUI : MonoBehaviour {
  4. public Camera VideoAd;
  5. public static MedaiPlayerSampleGUI Instance;
  6. public MediaPlayerCtrl scrMedia;
  7. public TextMesh GUIText;
  8. public GUIStyle style;
  9. public Sprite sprite;
  10. public float Timer = 10;
  11. public bool m_bFinish = false;
  12. public ScreenBase progressIndicator;
  13. void Start()
  14. {
  15. scrMedia.OnEnd += OnEnd;
  16. Instance = this;
  17. }
  18. void Update()
  19. {
  20. if (VideoAd.enabled)
  21. {
  22. Timer = Timer - Time.deltaTime;
  23. if (Timer <= 0)
  24. {
  25. Debug.Log("OnLeavingViewingVideoAd");
  26. MenuManager._instance.OnLeavingViewingVideoAd();
  27. }
  28. GUIText.text = ((int)Timer).ToString();
  29. }
  30. }
  31. void OnGUI()
  32. {
  33. if (VideoAd.enabled)
  34. {
  35. if (Timer <= 14)
  36. {
  37. if (GUI.Button(new Rect(10, 10, 100, 100), sprite.texture, style))
  38. {
  39. MenuManager._instance.OnLeavingViewingVideoAd();
  40. }
  41. }
  42. }
  43. }
  44. void OnEnd()
  45. {
  46. /*m_bFinish = true;
  47. Debug.Log("OnEnd");
  48. scrMedia.Stop();*/
  49. //MenuManager._instance.OnLeavingViewingVideoAd();
  50. }
  51. }