SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

4 years ago
  1. using System.Collections.Generic;
  2. using UnityEngine.Animations;
  3. using UnityEngine.Experimental.Animations;
  4. using UnityEngine.Playables;
  5. namespace UnityEngine.Timeline
  6. {
  7. class AnimationPreviewUpdateCallback : ITimelineEvaluateCallback
  8. {
  9. AnimationPlayableOutput m_Output;
  10. PlayableGraph m_Graph;
  11. List<IAnimationWindowPreview> m_PreviewComponents;
  12. public AnimationPreviewUpdateCallback(AnimationPlayableOutput output)
  13. {
  14. m_Output = output;
  15. Playable playable = m_Output.GetSourcePlayable();
  16. if (playable.IsValid())
  17. {
  18. m_Graph = playable.GetGraph();
  19. }
  20. }
  21. public void Evaluate()
  22. {
  23. if (!m_Graph.IsValid())
  24. return;
  25. if (m_PreviewComponents == null)
  26. FetchPreviewComponents();
  27. foreach (var component in m_PreviewComponents)
  28. {
  29. if (component != null)
  30. {
  31. component.UpdatePreviewGraph(m_Graph);
  32. }
  33. }
  34. }
  35. private void FetchPreviewComponents()
  36. {
  37. m_PreviewComponents = new List<IAnimationWindowPreview>();
  38. var animator = m_Output.GetTarget();
  39. if (animator == null)
  40. return;
  41. var gameObject = animator.gameObject;
  42. m_PreviewComponents.AddRange(gameObject.GetComponents<IAnimationWindowPreview>());
  43. }
  44. }
  45. }