ScriptPlayableAssetActivation.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. using UnityEngine.UI;
  6. [System.Serializable]
  7. public class ScriptPlayableAssetActivation : PlayableAsset, IPlayableAssetDeal
  8. {
  9. public int masterId;
  10. public StoryLocation location = StoryLocation.Left;
  11. public GameObject master;
  12. public float startTime;
  13. public float endTime;
  14. public StoryMgr mgr;
  15. bool isPlayed = false;
  16. bool isEnd = false;
  17. // Factory method that generates a playable based on this asset
  18. public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
  19. {
  20. ScriptPlayableTrackActivation activationPlayable = new ScriptPlayableTrackActivation();
  21. activationPlayable.Init(masterId, location, mgr);
  22. return ScriptPlayable<ScriptPlayableTrackActivation>.Create(graph, activationPlayable);
  23. }
  24. public void DealWithSimpleMode(int time)
  25. {
  26. if (master == null)
  27. return;
  28. if (time >= startTime && time < endTime)
  29. {
  30. if (!isPlayed)
  31. {
  32. isPlayed = true;
  33. StoryMgr.Instance.DisplaySrotyCM(master.transform, (StoryCMType)(location + 1));
  34. }
  35. }
  36. else if (time >= endTime)
  37. {
  38. if (!isEnd)
  39. {
  40. isEnd = true;
  41. StoryMgr.Instance.ResetSrotyCM(master.transform, (StoryCMType)(location + 1), StoryMgr.Instance.DefaultLayerName);
  42. }
  43. }
  44. }
  45. }