public IEnumerator EnsureMatchingAndLimitedFramesAreLoadedToScene() { InitTest(true, out PlayableDirector director, out SceneCachePlayer sceneCachePlayer, out TimelineClip clip0); yield return(null); ISceneCacheInfo scInfo = sceneCachePlayer.ExtractSceneCacheInfo(forceOpen: true); Assert.IsNotNull(scInfo); int numFrames = scInfo.GetNumFrames(); double timePerFrame = 1.0f / scInfo.GetSampleRate(); //Setup clip0 duration int halfFrames = Mathf.FloorToInt(numFrames * 0.5f); clip0.duration = halfFrames * timePerFrame; //Setup clip1 TimelineClip clip1 = clip0.GetParentTrack().CreateClip <SceneCachePlayableAsset>(); clip1.start = clip0.start + clip0.duration; clip1.clipIn = clip0.duration; clip1.duration = clip0.duration; SceneCachePlayableAsset playableAsset1 = clip1.asset as SceneCachePlayableAsset; Assert.IsNotNull(playableAsset1); director.SetReferenceValue(playableAsset1.GetSceneCachePlayerRef().exposedName, sceneCachePlayer); TimelineEditorUtility.RefreshTimelineEditor(RefreshReason.ContentsAddedOrRemoved | RefreshReason.WindowNeedsRedraw | RefreshReason.ContentsModified); yield return(null); //Setup Limited Animation const int NUM_FRAMES_TO_HOLD = 3; const int OFFSET = 1; LimitedAnimationController limitedAnimationController1 = playableAsset1.GetOverrideLimitedAnimationController(); limitedAnimationController1.Enable(NUM_FRAMES_TO_HOLD, OFFSET); yield return(IterateAllSceneCacheFrames(director, clip0, sceneCachePlayer, (int timelineFrame) => { EditorApplication.isPaused = true; Assert.AreEqual(timelineFrame, sceneCachePlayer.GetFrame()); })); yield return(IterateAllSceneCacheFrames(director, clip1, sceneCachePlayer, (int timelineFrame) => { int shownFrame = sceneCachePlayer.GetFrame(); if (shownFrame == (scInfo.GetNumFrames() - 1)) //clamped to the end frame { return; } Assert.Zero(shownFrame % NUM_FRAMES_TO_HOLD - OFFSET); })); }
//---------------------------------------------------------------------------------------------------------------------- private static void InitTest(bool enableSceneCacheGo, out PlayableDirector director, out SceneCachePlayer sceneCachePlayer, out TimelineClip clip) { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); director = CreateTestDirector(); sceneCachePlayer = CreateTestSceneCachePlayer(); sceneCachePlayer.gameObject.SetActive(enableSceneCacheGo); clip = SceneCachePlayerEditorUtility.AddSceneCacheTrackAndClip(director, "TestSceneCacheTrack", sceneCachePlayer); TimelineEditorUtility.SelectDirectorInTimelineWindow(director); //trigger the TimelineWindow's update etc. TimelineEditorUtility.RefreshTimelineEditor(); }
public IEnumerator CheckGameObjectActiveStateReferredInMultipleTracks() { InitTest(true, out PlayableDirector director, out SceneCachePlayer sceneCachePlayer, out TimelineClip clip0); yield return(null); TimelineClip clip1 = SceneCachePlayerEditorUtility.AddSceneCacheTrackAndClip(director, "TestSceneCacheTrack 1", sceneCachePlayer); clip1.start = clip0.end; TimelineEditorUtility.RefreshTimelineEditor(RefreshReason.ContentsAddedOrRemoved); yield return(null); GameObject scGameObject = sceneCachePlayer.gameObject; SetDirectorTime(director, clip0.start); yield return(null); Assert.IsTrue(scGameObject.activeSelf); SetDirectorTime(director, clip1.start + clip1.duration * 0.5f); yield return(null); Assert.IsTrue(scGameObject.activeSelf); }