private IEnumerator IterateAllSceneCacheFrames(PlayableDirector director, TimelineClip clip, SceneCachePlayer scPlayer,
                                                       Action <int> afterUpdateFunc)
        {
            ISceneCacheInfo scInfo = scPlayer.ExtractSceneCacheInfo(forceOpen: true);

            Assert.IsNotNull(scInfo);

            double timePerFrame = 1.0f / scInfo.GetSampleRate();

            //Use (numFrames-1) because when it becomes invisible when Timeline reaches the last frame
            for (int i = 0; i < scInfo.GetNumFrames() - 1; ++i)
            {
                double elapsedTime = i * timePerFrame;
                if (elapsedTime >= clip.duration)
                {
                    yield break;
                }

                double directorTime = clip.start + i * timePerFrame;
                SetDirectorTime(director, directorTime); //this will trigger change in the time of the SceneCachePlayable
                yield return(null);

                afterUpdateFunc(i);
            }
        }
Пример #2
0
        private static void DrawCacheInfo(SceneCachePlayer t)
        {
            ISceneCacheInfo scInfo = t.ExtractSceneCacheInfo(forceOpen: false);

            if (null == scInfo)
            {
                return;
            }

            t.ShowInfoInInspector(EditorGUILayout.Foldout(t.IsInfoInInspectorShown(), "Info", true, GetDefaultFoldoutStyle()));
            if (!t.IsInfoInInspectorShown())
            {
                return;
            }

            ++EditorGUI.indentLevel;

            const int leftWidth  = 160;
            int       numFrames  = scInfo.GetNumFrames();
            float     sampleRate = scInfo.GetSampleRate();
            TimeRange timeRange  = scInfo.GetTimeRange();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label($"Num Frames: {numFrames}", GUILayout.MaxWidth(leftWidth));
            GUILayout.Label($"Start Time: {timeRange.start,15:N4}");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label($"Frame Rate: {sampleRate}", GUILayout.MaxWidth(leftWidth));
            GUILayout.Label($"End Time  : {timeRange.end,15:N4}");
            EditorGUILayout.EndHorizontal();

            --EditorGUI.indentLevel;

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }