//---------------------------------------------------------------------------------------------------------------------- internal static void LockAndEditPlayableFrame(SISPlayableFrame playableFrame, RenderCachePlayableAsset renderCachePlayableAsset) { int index = playableFrame.GetIndex(); string filePath = renderCachePlayableAsset.GetImageFilePath(index); if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { EditorUtility.DisplayDialog(StreamingImageSequenceConstants.DIALOG_HEADER, "Please update RenderCachePlayableAsset.", "Ok"); return; } string fullPath = Path.GetFullPath(filePath); playableFrame.SetLocked(true); string imageAppPath = EditorPrefs.GetString("kImagesDefaultApp"); if (string.IsNullOrEmpty(imageAppPath) || !File.Exists(imageAppPath)) { System.Diagnostics.Process.Start(fullPath); return; } System.Diagnostics.Process.Start(imageAppPath, fullPath); }
//---------------------------------------------------------------------------------------------------------------------- void DrawPreviewImage(ref PreviewDrawInfo drawInfo, TimelineClip clip, RenderCachePlayableAsset renderCachePlayableAsset) { double normalizedLocalTime = drawInfo.LocalTime / clip.duration; IList <string> imageFileNames = renderCachePlayableAsset.GetImageFileNames(); Assert.IsNotNull(imageFileNames); int count = imageFileNames.Count; Assert.IsTrue(imageFileNames.Count > 0); int index = Mathf.RoundToInt(count * (float)normalizedLocalTime); index = Mathf.Clamp(index, 0, count - 1); //Load string imagePath = renderCachePlayableAsset.GetImageFilePath(index); if (!File.Exists(imagePath)) { return; } ImageLoader.GetImageDataInto(imagePath, StreamingImageSequenceConstants.IMAGE_TYPE_PREVIEW , out ImageData imageData); switch (imageData.ReadStatus) { case StreamingImageSequenceConstants.READ_STATUS_LOADING: break; case StreamingImageSequenceConstants.READ_STATUS_SUCCESS: { Texture2D tex = PreviewTextureFactory.GetOrCreate(imagePath, ref imageData); if (null != tex) { Graphics.DrawTexture(drawInfo.DrawRect, tex); } break; } default: { ImageLoader.RequestLoadPreviewImage(imagePath, (int)drawInfo.DrawRect.width, (int)drawInfo.DrawRect.height); break; } } }
//---------------------------------------------------------------------------------------------------------------------- internal static void LockAndEditPlayableFrame(SISPlayableFrame playableFrame, RenderCachePlayableAsset renderCachePlayableAsset) { int index = playableFrame.GetIndex(); string filePath = renderCachePlayableAsset.GetImageFilePath(index); if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { EditorUtility.DisplayDialog(StreamingImageSequenceConstants.DIALOG_HEADER, "Please update RenderCachePlayableAsset.", "Ok"); return; } playableFrame.SetLocked(true); LaunchImageApplicationExternalTool(Path.GetFullPath(filePath)); }
public IEnumerator UpdateRenderCachePNGInStreamingAssets() { PlayableDirector director = EditorUtilityTest.NewSceneWithDirector(); TimelineClip clip = EditorUtilityTest.CreateTestRenderCacheTimelineClip(director); TimelineAsset timelineAsset = director.playableAsset as TimelineAsset; RenderCachePlayableAsset renderCachePlayableAsset = clip.asset as RenderCachePlayableAsset; RenderCacheTrack track = clip.GetParentTrack() as RenderCacheTrack; Assert.IsNotNull(timelineAsset); Assert.IsNotNull(renderCachePlayableAsset); Assert.IsNotNull(track); Assert.IsNotNull(Camera.main); yield return(null); clip.duration = (1.0f / timelineAsset.editorSettings.GetFPS()); const string OUTPUT_FOLDER = "Asset/StreamingAssets/RenderCachePNGForTestRunner"; Directory.CreateDirectory(OUTPUT_FOLDER); renderCachePlayableAsset.SetFolder(OUTPUT_FOLDER); GameObject cameraRenderCapturerGO = new GameObject(); CameraRenderCapturer cameraRenderCapturer = cameraRenderCapturerGO.AddComponent <CameraRenderCapturer>(); cameraRenderCapturer.SetCamera(Camera.main); director.SetGenericBinding(track, cameraRenderCapturer); yield return(null); //Update RenderCache EditorCoroutineUtility.StartCoroutineOwnerless( RenderCachePlayableAssetInspector.UpdateRenderCacheCoroutine(director, renderCachePlayableAsset) ); //A hack to wait until the coroutine is finished const float TIMEOUT_SEC = 3.0f; Assert.IsTrue(Directory.Exists(OUTPUT_FOLDER)); float prevTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - prevTime < TIMEOUT_SEC) { yield return(null); } string imageFilePath = renderCachePlayableAsset.GetImageFilePath(0); Assert.IsTrue(File.Exists(imageFilePath)); ImageLoader.RequestLoadFullImage(imageFilePath); //Another hack to wait until the load is finished prevTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - prevTime < TIMEOUT_SEC) { yield return(null); } ImageLoader.GetImageDataInto(imageFilePath, StreamingImageSequenceConstants.IMAGE_TYPE_FULL, out ImageData imageData); Assert.AreEqual(StreamingImageSequenceConstants.READ_STATUS_SUCCESS, imageData.ReadStatus); yield return(null); //cleanup StreamingImageSequencePlugin.UnloadAllImages(); bool folderDeleted = FileUtility.DeleteFilesAndFolders(OUTPUT_FOLDER); Assert.IsTrue(folderDeleted); EditorUtilityTest.DestroyTestTimelineAssets(clip); yield return(null); }