//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } StreamingImageSequenceTrack sisTrack = track as StreamingImageSequenceTrack; Assert.IsNotNull(sisTrack); //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.parentTrack = track; //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { if (asset.HasImages()) { clip.duration = asset.GetImageFileNames().Count * 0.125; // 8fps (standard limited animation) clip.displayName = Path.GetFileName(asset.GetFolder()); } clip.CreateCurves("Curves: " + clip.displayName); } TimelineClipSISData sisData = null; asset.InitTimelineClipCurve(clip); if (null == clonedFrom) { sisData = new TimelineClipSISData(clip); asset.BindTimelineClipSISData(sisData); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); TimelineClipSISData otherSISData = clonedFromAsset.GetBoundTimelineClipSISData(); sisData = new TimelineClipSISData(clip, otherSISData); asset.BindTimelineClipSISData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override ClipDrawOptions GetClipOptions(TimelineClip clip) { var clipOptions = base.GetClipOptions(clip); StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return(clipOptions); } string folder = asset.GetFolder(); if (string.IsNullOrEmpty(folder)) { clipOptions.errorText = NO_FOLDER_ASSIGNED_ERROR; } else if (!Directory.Exists(folder)) { clipOptions.errorText = FOLDER_MISSING_ERROR; } else if (asset.GetImageFileNames() == null) { clipOptions.errorText = NO_PICTURES_ASSIGNED_ERROR; } clipOptions.tooltip = folder; return(clipOptions); }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override ClipDrawOptions GetClipOptions(TimelineClip clip) { ClipDrawOptions clipOptions = base.GetClipOptions(clip); StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return(clipOptions); } string folder = asset.GetFolder(); if (string.IsNullOrEmpty(folder)) { clipOptions.errorText = NO_FOLDER_ASSIGNED_ERROR; } else if (!Directory.Exists(folder)) { clipOptions.errorText = FOLDER_MISSING_ERROR; } else if (asset.GetNumImages() <= 0) { clipOptions.errorText = NO_PICTURES_ASSIGNED_ERROR; } clipOptions.tooltip = folder; #if AT_USE_TIMELINE_GE_1_6_0 clipOptions.hideScaleIndicator = true; #endif return(clipOptions); }
public IEnumerator ImportFromStreamingAssets() { PlayableDirector director = EditorUtilityTest.NewSceneWithDirector(); TimelineClip clip = EditorUtilityTest.CreateTestTimelineClip(director); StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(sisAsset); //Copy test data to streamingAssetsPath const string DEST_FOLDER_NAME = "ImportFromStreamingAssetsTest"; string streamingAssetsFolder = AssetEditorUtility.NormalizeAssetPath(Application.streamingAssetsPath); string destFolderGUID = AssetDatabase.CreateFolder(streamingAssetsFolder, DEST_FOLDER_NAME); string destFolder = AssetDatabase.GUIDToAssetPath(destFolderGUID); string srcFolder = sisAsset.GetFolder(); IList <string> imageFileNames = sisAsset.GetImageFileNames(); foreach (string imageFileName in imageFileNames) { string src = Path.Combine(srcFolder, imageFileName); string dest = Path.Combine(destFolder, imageFileName); 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); }
public IEnumerator ReloadPlayableAsset() { PlayableDirector director = EditorUtilityTest.NewSceneWithDirector(); TimelineClip clip = EditorUtilityTest.CreateTestSISTimelineClip(director); StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(sisAsset); string folder = sisAsset.GetFolder(); Assert.IsNotNull(folder); int numOriginalImages = sisAsset.GetNumImages(); Assert.Greater(numOriginalImages, 0); List <WatchedFileInfo> testImages = sisAsset.FindImages(folder); List <string> copiedImagePaths = new List <string>(testImages.Count); foreach (WatchedFileInfo imageFile in testImages) { string fileName = imageFile.GetName(); string src = Path.Combine(folder, fileName); string dest = Path.Combine(folder, "Copied_" + fileName); File.Copy(src, dest, true); copiedImagePaths.Add(dest); } yield return(null); sisAsset.Reload(); yield return(null); Assert.AreEqual(numOriginalImages * 2, sisAsset.GetNumImages()); //Cleanup foreach (string imagePath in copiedImagePaths) { File.Delete(imagePath); } EditorUtilityTest.DestroyTestTimelineAssets(clip); yield return(null); }
//---------------------------------------------------------------------------------------------------------------------- /// <inheritdoc/> public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { StreamingImageSequencePlayableAsset asset = clip.asset as StreamingImageSequencePlayableAsset; if (null == asset) { Debug.LogError("Asset is not a StreamingImageSequencePlayableAsset: " + clip.asset); return; } //[Note-sin: 2021-2-25] Track can be null during copy and paste if (null != track) { //This callback occurs before the clip is assigned to the track, but we need the track for creating curves. clip.TryMoveToTrack(track); } //If we have a default asset, and clonedFrom is NULL, which means this is created by user interaction, //such as Folder D&D UnityEditor.DefaultAsset timelineDefaultAsset = asset.GetTimelineDefaultAsset(); if (null != timelineDefaultAsset && null == clonedFrom) { InitializeAssetFromDefaultAsset(asset, timelineDefaultAsset); } //If the clip already has curves (because of cloning, etc), then we don't set anything if (null == clip.curves) { int numImages = asset.GetNumImages(); if (numImages > 0) { SISUserSettings userSettings = SISUserSettings.GetInstance(); clip.duration = (double)(numImages) / (userSettings.GetDefaultSISPlayableAssetFPS()); clip.displayName = Path.GetFileName(asset.GetFolder()); } ExtendedClipEditorUtility.CreateTimelineClipCurve(clip, StreamingImageSequencePlayableAsset.GetTimeCurveBinding()); } if (null == clonedFrom) { asset.BindClipData(new SISClipData(clip)); return; } //Duplicate/Split process StreamingImageSequencePlayableAsset clonedFromAsset = clonedFrom.asset as StreamingImageSequencePlayableAsset; Assert.IsNotNull(clonedFromAsset); SISClipData otherSISData = clonedFromAsset.GetBoundClipData(); if (null == otherSISData) { asset.BindClipData(new SISClipData(clip)); //[Note-sin: 2021-2-25] can be null during copy and paste return; } SISClipData sisData = new SISClipData(clip, otherSISData); asset.BindClipData(sisData); clip.displayName = clonedFrom.displayName + " (Cloned)"; }