//---------------------------------------------------------------------------------------------------------------------- void DrawPreviewImage(ref PreviewDrawInfo drawInfo, TimelineClip clip, StreamingImageSequencePlayableAsset sisAsset) { int imageIndex = sisAsset.LocalTimeToImageIndex(clip, drawInfo.LocalTime); IList <string> imageFileNames = sisAsset.GetImageFileNames(); //Load string imagePath = sisAsset.GetImageFilePath(imageIndex); ImageLoader.GetImageDataInto(imagePath, StreamingImageSequenceConstants.IMAGE_TYPE_PREVIEW , out ImageData readResult); switch (readResult.ReadStatus) { case StreamingImageSequenceConstants.READ_STATUS_LOADING: break; case StreamingImageSequenceConstants.READ_STATUS_SUCCESS: { Texture2D tex = PreviewTextureFactory.GetOrCreate(imagePath, ref readResult); if (null != tex) { Graphics.DrawTexture(drawInfo.DrawRect, tex); } break; } default: { ImageLoader.RequestLoadPreviewImage(imagePath, (int)drawInfo.DrawRect.width, (int)drawInfo.DrawRect.height); break; } } }
//---------------------------------------------------------------------------------------------------------------------- protected override void DrawPreviewImageV(ref PreviewDrawInfo drawInfo, TimelineClip clip, ImageFolderPlayableAsset <SISClipData> playableAsset) { StreamingImageSequencePlayableAsset sisAsset = playableAsset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(sisAsset); int imageIndex = sisAsset.LocalTimeToImageIndex(clip, drawInfo.LocalTime); string imagePath = sisAsset.GetImageFilePath(imageIndex); PreviewUtility.DrawPreviewImage(ref drawInfo, imagePath); }
internal static void EditPlayableFrame(SISPlayableFrame playableFrame, StreamingImageSequencePlayableAsset sisPlayableAsset) { //Find the correct imageIndex. The number of frames in the clip may be more/less than the number of images int playableFrameIndex = playableFrame.GetIndex(); int numPlayableFrames = sisPlayableAsset.GetBoundClipData().GetNumPlayableFrames(); int numImages = sisPlayableAsset.GetNumImages(); int index = Mathf.FloorToInt(playableFrameIndex * ((float)numImages / numPlayableFrames)); string filePath = sisPlayableAsset.GetImageFilePath(index); if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { EditorUtility.DisplayDialog(StreamingImageSequenceConstants.DIALOG_HEADER, "Image does not exist: " + filePath, "Ok"); return; } LaunchImageApplicationExternalTool(Path.GetFullPath(filePath)); }
public IEnumerator ImportFromStreamingAssets() { PlayableDirector director = EditorUtilityTest.NewSceneWithDirector(); TimelineClip clip = EditorUtilityTest.CreateTestSISTimelineClip(director); StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(sisAsset); //Copy test data to streamingAssetsPath const string DEST_FOLDER_NAME = "ImportFromStreamingAssetsTest"; string streamingAssetsFolder = AssetUtility.NormalizeAssetPath(Application.streamingAssetsPath); string destFolderGUID = AssetDatabase.CreateFolder(streamingAssetsFolder, DEST_FOLDER_NAME); string destFolder = AssetDatabase.GUIDToAssetPath(destFolderGUID); int numImages = sisAsset.GetNumImages(); for (int i = 0; i < numImages; ++i) { string src = sisAsset.GetImageFilePath(i); Assert.IsNotNull(src); string dest = Path.Combine(destFolder, Path.GetFileName(src)); File.Copy(src, dest, true); } AssetDatabase.Refresh(); yield return(null); ImageSequenceImporter.ImportImages(destFolder, sisAsset); yield return(null); Assert.AreEqual(destFolder, sisAsset.GetFolder()); //Cleanup AssetDatabase.DeleteAsset(destFolder); EditorUtilityTest.DestroyTestTimelineAssets(clip); yield return(null); }