VideoScriptPlayableAsset.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Playables;
  4. using UnityEngine.Video;
  5. namespace UnityEngine.Timeline
  6. {
  7. [Serializable]
  8. public class VideoScriptPlayableAsset : PlayableAsset
  9. {
  10. public ExposedReference<VideoPlayer> videoPlayer;
  11. [SerializeField, NotKeyable]
  12. public VideoClip videoClip;
  13. [SerializeField, NotKeyable]
  14. public bool mute = false;
  15. [SerializeField, NotKeyable]
  16. public bool loop = true;
  17. [SerializeField, NotKeyable]
  18. public double preloadTime = 0.3;
  19. [SerializeField, NotKeyable]
  20. public double clipInTime = 0.0;
  21. public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
  22. {
  23. ScriptPlayable<VideoPlayableBehaviour> playable =
  24. ScriptPlayable<VideoPlayableBehaviour>.Create(graph);
  25. VideoPlayableBehaviour playableBehaviour = playable.GetBehaviour();
  26. playableBehaviour.videoPlayer = videoPlayer.Resolve(graph.GetResolver());
  27. playableBehaviour.videoClip = videoClip;
  28. playableBehaviour.mute = mute;
  29. playableBehaviour.loop = loop;
  30. playableBehaviour.preloadTime = preloadTime;
  31. playableBehaviour.clipInTime = clipInTime;
  32. return playable;
  33. }
  34. }
  35. }