Exemple #1
0
//----------------------------------------------------------------------------------------------------------------------
        private static SISPlayableFrame CreatePlayableFrame(TimelineClipSISData owner, int index, double timePerFrame)
        {
            SISPlayableFrame playableFrame = new SISPlayableFrame(owner);

            playableFrame.SetIndexAndLocalTime(index, timePerFrame * index);
            return(playableFrame);
        }
//----------------------------------------------------------------------------------------------------------------------
        /// <inheritdoc/>
        protected override void OnBeforeTrackSerialize()
        {
            base.OnBeforeTrackSerialize();
            m_serializedSISDataCollection = new List <TimelineClipSISData>();

            foreach (TimelineClip clip in GetClips())
            {
                TimelineClipSISData sisData = null;

                if (null != m_sisDataCollection && m_sisDataCollection.ContainsKey(clip))
                {
                    sisData = m_sisDataCollection[clip];
                }
                else
                {
                    T sisPlayableAsset = clip.asset as T;
                    Assert.IsNotNull(sisPlayableAsset);
                    sisData = sisPlayableAsset.GetBoundTimelineClipSISData();
                }

                if (null == sisData)
                {
                    sisData = new TimelineClipSISData(clip);
                }


                m_serializedSISDataCollection.Add(sisData);
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        //Calculate the used image index for the passed localTime
        internal int LocalTimeToImageIndex(TimelineClip clip, double localTime)
        {
            TimelineClipSISData timelineSISData = GetBoundTimelineClipSISData();

            if (null != timelineSISData)
            {
                double scaledTimePerFrame = TimelineUtility.CalculateTimePerFrame(clip) * clip.timeScale;

                //Try to check if this frame is "dropped", so that we should use the image in the prev frame
                int playableFrameIndex         = Mathf.RoundToInt((float)localTime / (float)scaledTimePerFrame);
                SISPlayableFrame playableFrame = timelineSISData.GetPlayableFrame(playableFrameIndex);
                while (playableFrameIndex > 0 && !playableFrame.IsUsed())
                {
                    --playableFrameIndex;
                    playableFrame = timelineSISData.GetPlayableFrame(playableFrameIndex);
                    localTime     = playableFrameIndex * scaledTimePerFrame;
                }
            }


            double imageSequenceTime = LocalTimeToCurveTime(clip, localTime);
            int    count             = m_imageFiles.Count;

            //Can't round up, because if the time for the next frame hasn't been reached, then we should stick
            int index = Mathf.FloorToInt(count * (float)imageSequenceTime);

            index = Mathf.Clamp(index, 0, count - 1);
            return(index);
        }
//----------------------------------------------------------------------------------------------------------------------
        private void InitTimelineClipSISData()
        {
            //Initialize PlayableAssets and TimelineClipSISData
            foreach (TimelineClip clip in GetClips())
            {
                T sisPlayableAsset = clip.asset as T;
                Assert.IsNotNull(sisPlayableAsset);

                TimelineClipSISData timelineClipSISData = sisPlayableAsset.GetBoundTimelineClipSISData();
                if (null == timelineClipSISData)
                {
                    timelineClipSISData = GetOrCreateTimelineClipSISData(clip);
                }
                else
                {
                    if (!m_sisDataCollection.ContainsKey(clip))
                    {
                        m_sisDataCollection.Add(clip, timelineClipSISData);;
                    }
                }

                //Make sure that the clip is the owner
                timelineClipSISData.SetOwner(clip);
                sisPlayableAsset.BindTimelineClipSISData(timelineClipSISData);
            }
        }
Exemple #5
0
        internal TimelineClipSISData(TimelineClip owner, TimelineClipSISData other) : this(owner){
            Assert.IsNotNull(m_playableFrames);

            foreach (SISPlayableFrame otherFrame in other.m_playableFrames)
            {
                SISPlayableFrame newFrame = new SISPlayableFrame(this, otherFrame);
                m_playableFrames.Add(newFrame);
            }

            m_frameMarkersRequested = other.m_frameMarkersRequested;
        }
//----------------------------------------------------------------------------------------------------------------------
        private TimelineClipSISData GetOrCreateTimelineClipSISData(TimelineClip clip)
        {
            Assert.IsNotNull(m_sisDataCollection);

            if (m_sisDataCollection.ContainsKey(clip))
            {
                return(m_sisDataCollection[clip]);
            }

            TimelineClipSISData sisData = new TimelineClipSISData(clip);

            m_sisDataCollection[clip] = sisData;
            return(sisData);
        }
        /// <inheritdoc/>
        protected override void OnAfterTrackDeserialize()
        {
            base.OnAfterTrackDeserialize();
            m_sisDataCollection = new Dictionary <TimelineClip, TimelineClipSISData>();


            IEnumerator <TimelineClip> clipEnumerator = GetClips().GetEnumerator();

            List <TimelineClipSISData> .Enumerator sisEnumerator = m_serializedSISDataCollection.GetEnumerator();
            while (clipEnumerator.MoveNext() && sisEnumerator.MoveNext())
            {
                TimelineClip clip = clipEnumerator.Current;
                Assert.IsNotNull(clip);

                TimelineClipSISData timelineClipSISData = sisEnumerator.Current;
                Assert.IsNotNull(timelineClipSISData);

                m_sisDataCollection[clip] = timelineClipSISData;
            }
            clipEnumerator.Dispose();
            sisEnumerator.Dispose();
        }
Exemple #8
0
//----------------------------------------------------------------------------------------------------------------------

        //These methods are necessary "hacks" for knowing the PlayableFrames/FrameMarkers that belong to this
        //this StreamingImageSequencePlayableAssets
        internal void BindTimelineClipSISData(TimelineClipSISData sisData)
        {
            m_timelineClipSISData = sisData;
        }
Exemple #9
0
//----------------------------------------------------------------------------------------------------------------------
        internal void SetOwner(TimelineClipSISData owner)
        {
            m_timelineClipSISDataOwner = owner;
        }
Exemple #10
0
 internal SISPlayableFrame(TimelineClipSISData owner, SISPlayableFrame otherFrame)
 {
     m_timelineClipSISDataOwner = owner;
     m_boolProperties           = otherFrame.m_boolProperties;
     m_localTime = otherFrame.m_localTime;
 }
Exemple #11
0
 internal SISPlayableFrame(TimelineClipSISData owner)
 {
     m_timelineClipSISDataOwner = owner;
     m_boolProperties           = new Dictionary <PlayableFramePropertyID, PlayableFrameBoolProperty>();
 }