1- using System . Collections ;
2- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
32using System ;
4- using System . IO ;
5- using UnityEngine ;
63using UnityEngine . Playables ;
7- using System . Text . RegularExpressions ;
8- using UnityEngine . Assertions ;
9- using System . Threading ;
10- using System . Runtime . InteropServices ;
114using UnityEngine . UI ;
125using UnityEngine . Timeline ;
136#if UNITY_EDITOR
@@ -29,7 +22,6 @@ public StreamingImageSequencePlayableMixer() {
2922 m_gameView = EditorWindow . GetWindow ( type , false , null , false ) ;
3023
3124#endif
32- m_loadStartOffsetTime = - 1.0 ;
3325 }
3426
3527
@@ -74,21 +66,17 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
7466 return ; // it doesn't work as mixer.
7567 }
7668
77- if ( m_nextInadvanceLoadingFrameArray == null ) {
78- m_nextInadvanceLoadingFrameArray = new int [ inputCount ] ;
69+ if ( m_nextInAdvanceLoadingFrameArray == null ) {
70+ m_nextInAdvanceLoadingFrameArray = new int [ inputCount ] ;
7971 for ( int ii = 0 ; ii < inputCount ; ii ++ )
8072 {
81- m_nextInadvanceLoadingFrameArray [ ii ] = 0 ;
73+ m_nextInAdvanceLoadingFrameArray [ ii ] = 0 ;
8274 }
8375 }
8476
85- GameObject go = GetBoundGameObject ( ) ;
86-
87- if ( null == go )
88- return ;
89-
9077 double directorTime = GetPlayableDirector ( ) . time ;
9178
79+ bool activeTimelineClipFound = false ;
9280 int i = 0 ;
9381 foreach ( TimelineClip clip in GetClips ( ) ) {
9482
@@ -100,30 +88,31 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
10088 if ( null == imagePaths )
10189 continue ;
10290
103- int count = imagePaths . Count ;
104- double clipDuration = clip . duration ;
10591 double startTime = clip . start ;
10692 double endTime = clip . end ;
10793
108- if ( m_loadStartOffsetTime < 0.0 ) {
109- m_loadStartOffsetTime = 1.0f + count * 0.1f ;
110-
111- }
94+ double loadStartOffsetTime = 1.0f + imagePaths . Count * 0.1f ;
11295
11396 //Load clips that might still be inactive, in advance
114- if ( directorTime >= startTime - m_loadStartOffsetTime && directorTime < endTime ) {
97+ if ( directorTime >= startTime - loadStartOffsetTime && directorTime < endTime ) {
11598 ProcessInAdvanceLoading ( directorTime , clip , i ) ;
11699 }
117100
118- if ( directorTime >= startTime && directorTime < endTime ) {
119-
101+ if ( ! activeTimelineClipFound && directorTime >= startTime && directorTime < endTime ) {
120102 ProcessActiveClipV ( asset , directorTime , clip ) ;
121- go . SetActive ( true ) ;
103+ activeTimelineClipFound = true ;
122104 }
123105
124106 ++ i ;
125107 }
126108
109+ //Show game object
110+ GameObject go = GetBoundGameObject ( ) ;
111+ if ( activeTimelineClipFound && null != go ) {
112+ go . SetActive ( true ) ;
113+ }
114+
115+
127116 }
128117
129118#endregion
@@ -137,21 +126,20 @@ private void ProcessInAdvanceLoading(double time, TimelineClip clip, int index)
137126
138127 int count = asset . GetImagePaths ( ) . Count ;
139128
140- if ( m_nextInadvanceLoadingFrameArray [ index ] < count )
129+ if ( m_nextInAdvanceLoadingFrameArray [ index ] < count )
141130 {
142131 for ( int check = 0 ; check < 4 ; check ++ )
143132 {
144133
145- if ( m_nextInadvanceLoadingFrameArray [ index ] >= 0 && m_nextInadvanceLoadingFrameArray [ index ] <= count )
134+ if ( m_nextInAdvanceLoadingFrameArray [ index ] >= 0 && m_nextInAdvanceLoadingFrameArray [ index ] <= count )
146135 {
147- if ( ! asset . IsLoadRequested ( m_nextInadvanceLoadingFrameArray [ index ] ) )
136+ if ( ! asset . IsLoadRequested ( m_nextInAdvanceLoadingFrameArray [ index ] ) )
148137 {
149- ReadResult result = new ReadResult ( ) ;
150- asset . LoadRequest ( m_nextInadvanceLoadingFrameArray [ index ] , false , out result ) ;
138+ asset . LoadRequest ( m_nextInAdvanceLoadingFrameArray [ index ] , false , out _ ) ;
151139 }
152140 }
153- m_nextInadvanceLoadingFrameArray [ index ] ++ ;
154- if ( m_nextInadvanceLoadingFrameArray [ index ] >= count )
141+ m_nextInAdvanceLoadingFrameArray [ index ] ++ ;
142+ if ( m_nextInAdvanceLoadingFrameArray [ index ] >= count )
155143 {
156144 break ;
157145 }
@@ -183,7 +171,6 @@ protected override void ProcessActiveClipV(StreamingImageSequencePlayableAsset a
183171//----------------------------------------------------------------------------------------------------------------------
184172
185173 void Reset ( ) {
186- m_loadStartOffsetTime = - 1.0 ;
187174 m_spriteRenderer = null ;
188175 m_image = null ;
189176 m_meshRenderer = null ;
@@ -238,15 +225,13 @@ void UpdateRendererTexture(StreamingImageSequencePlayableAsset asset) {
238225 private MeshRenderer m_meshRenderer = null ;
239226 private Image m_image = null ;
240227
241- internal TrackAsset m_track ;
242- private double m_loadStartOffsetTime ;
243228#if UNITY_EDITOR
244- EditorWindow m_gameView ;
229+ readonly EditorWindow m_gameView ;
245230#endif
246- private int [ ] m_nextInadvanceLoadingFrameArray ;
231+ private int [ ] m_nextInAdvanceLoadingFrameArray ;
247232
248233 }
249234
250235
251236
252- }
237+ } //end namespace
0 commit comments