TemplateVideo.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class TemplateVideo : BaseTemPlate
  6. {
  7. private VideoControl m_VideoCtr;
  8. protected override void OnEnable()
  9. {
  10. base.OnEnable();
  11. if (GameManager.Instance.IsRuning && string.IsNullOrWhiteSpace(m_VideoCtr.VideoURL))
  12. {
  13. if (File.Exists(Data.localSavePath))
  14. {
  15. m_VideoCtr.VideoURL = Data.localSavePath;
  16. }
  17. else
  18. {
  19. m_VideoCtr.VideoURL = null;
  20. }
  21. }
  22. m_VideoCtr.m_IsPlaying = false;
  23. m_VideoCtr.PlayVideo();
  24. }
  25. protected override void OnAwake()
  26. {
  27. base.OnAwake();
  28. m_VideoCtr = transform.Find("Screen/Video").GetComponent<VideoControl>();
  29. HideCollider();
  30. }
  31. public override void SetData(MaterialObjValue value, int updateTime)
  32. {
  33. base.SetData(value, updateTime);
  34. if (!GameManager.Instance.IsRuning)
  35. {
  36. DownloadManager.Instance.AddDownloadData(Data);
  37. }
  38. else
  39. {
  40. if (File.Exists(Data.localSavePath))
  41. {
  42. m_VideoCtr.VideoURL = Data.localSavePath;
  43. }
  44. else
  45. {
  46. m_VideoCtr.VideoURL = null;
  47. }
  48. }
  49. }
  50. public override void HideCollider()
  51. {
  52. base.HideCollider();
  53. }
  54. }