12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using UnityEngine.Playables;
- namespace UnityEngine.Timeline
- {
-
-
-
- public class TimeControlPlayable : PlayableBehaviour
- {
- ITimeControl m_timeControl;
- bool m_started;
-
-
-
-
-
-
- public static ScriptPlayable<TimeControlPlayable> Create(PlayableGraph graph, ITimeControl timeControl)
- {
- if (timeControl == null)
- return ScriptPlayable<TimeControlPlayable>.Null;
- var handle = ScriptPlayable<TimeControlPlayable>.Create(graph);
- handle.GetBehaviour().Initialize(timeControl);
- return handle;
- }
-
-
-
-
- public void Initialize(ITimeControl timeControl)
- {
- m_timeControl = timeControl;
- }
-
-
-
-
-
- public override void PrepareFrame(Playable playable, FrameData info)
- {
- Debug.Assert(m_started, "PrepareFrame has been called without OnControlTimeStart being called first.");
- if (m_timeControl != null)
- m_timeControl.SetTime(playable.GetTime());
- }
-
-
-
-
-
- public override void OnBehaviourPlay(Playable playable, FrameData info)
- {
- if (m_timeControl == null)
- return;
- if (!m_started)
- {
- m_timeControl.OnControlTimeStart();
- m_started = true;
- }
- }
-
-
-
-
-
- public override void OnBehaviourPause(Playable playable, FrameData info)
- {
- if (m_timeControl == null)
- return;
- if (m_started)
- {
- m_timeControl.OnControlTimeStop();
- m_started = false;
- }
- }
- }
- }
|