summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Evaluation/InfiniteRuntimeClip.cs
blob: e833fd5b1a3b004ac843abbb2bb133d1464d936e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using UnityEngine.Playables;

namespace UnityEngine.Timeline
{
    /// <summary>
    /// Runtime clip customized for 'infinite' tracks playables.
    /// Used for clips whose time needs to match the timelines exactly
    /// </summary>
    class InfiniteRuntimeClip : RuntimeElement
    {
        private Playable m_Playable;
        private static readonly Int64 kIntervalEnd = DiscreteTime.GetNearestTick(TimelineClip.kMaxTimeValue);

        public InfiniteRuntimeClip(Playable playable)
        {
            m_Playable = playable;
        }

        public override Int64 intervalStart
        {
            get { return 0; }
        }

        public override Int64 intervalEnd
        {
            get { return kIntervalEnd; }
        }

        public override bool enable
        {
            set
            {
                if (value)
                    m_Playable.Play();
                else
                    m_Playable.Pause();
            }
        }

        public override void EvaluateAt(double localTime, FrameData frameData)
        {
            m_Playable.SetTime(localTime);
        }
    }
}