diff --git a/Assets/FlashTools/Scripts/Editor/FTEditor/Editors/SwfAssetEditor.cs b/Assets/FlashTools/Scripts/Editor/FTEditor/Editors/SwfAssetEditor.cs index 9ed0d2e..83e1216 100644 --- a/Assets/FlashTools/Scripts/Editor/FTEditor/Editors/SwfAssetEditor.cs +++ b/Assets/FlashTools/Scripts/Editor/FTEditor/Editors/SwfAssetEditor.cs @@ -42,8 +42,9 @@ namespace FTEditor.Editors { } static void ReconvertAsset(SwfAsset asset) { - AssetDatabase.ImportAsset( - AssetDatabase.GetAssetPath(asset)); + asset.Atlas = null; + EditorUtility.SetDirty(asset); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(asset)); } // diff --git a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfAssetPostprocessor.cs b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfAssetPostprocessor.cs index bdea1ca..97e87ed 100644 --- a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfAssetPostprocessor.cs +++ b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfAssetPostprocessor.cs @@ -10,8 +10,7 @@ using FTRuntime; namespace FTEditor.Postprocessors { class SwfAssetPostprocessor : AssetPostprocessor { - static SwfEditorUtils.ProgressBar _progressBar = new SwfEditorUtils.ProgressBar(); - static Queue _assetsForProcess = new Queue(); + static SwfEditorUtils.ProgressBar _progressBar = new SwfEditorUtils.ProgressBar(); static void OnPostprocessAllAssets( string[] imported_assets, @@ -25,38 +24,27 @@ namespace FTEditor.Postprocessors { .Select(p => AssetDatabase.LoadAssetAtPath(p)) .Where(p => !!p); foreach ( var asset in assets ) { - if ( !_assetsForProcess.Contains(asset) ) { - _assetsForProcess.Enqueue(asset); - } - } - if ( _assetsForProcess.Count > 0 ) { - EditorApplication.update += ProcessAfterImport; - } - } - - static void ProcessAfterImport() { - EditorApplication.update -= ProcessAfterImport; - if ( _assetsForProcess.Count > 0 ) { - while ( _assetsForProcess.Count > 0 ) { - SwfAssetProcess(_assetsForProcess.Dequeue()); - } - AssetDatabase.SaveAssets(); + EditorApplication.delayCall += () => { + SwfAssetProcess(asset); + AssetDatabase.SaveAssets(); + }; } } static void SwfAssetProcess(SwfAsset asset) { try { - _progressBar.UpdateTitle(asset.name); - var new_data = ConfigureBitmaps( - asset, - SwfEditorUtils.DecompressAsset(asset.Data)); - asset.Data = SwfEditorUtils.CompressAsset(new_data); - asset.Atlas = LoadAssetAtlas(asset); - if ( asset.Atlas ) { - ConfigureAtlas(asset); - ConfigureClips( + if ( !asset.Atlas ) { + _progressBar.UpdateTitle(asset.name); + var new_data = ConfigureBitmaps( asset, SwfEditorUtils.DecompressAsset(asset.Data)); + asset.Data = SwfEditorUtils.CompressAsset(new_data); + asset.Atlas = LoadAssetAtlas(asset); + if ( asset.Atlas ) { + ConfigureAtlas(asset); + ConfigureClips(asset, new_data); + } + EditorUtility.SetDirty(asset); } } catch ( Exception e ) { Debug.LogErrorFormat( @@ -140,7 +128,6 @@ namespace FTEditor.Postprocessors { File.WriteAllBytes(atlas_path, atlas_info.Atlas.EncodeToPNG()); GameObject.DestroyImmediate(atlas_info.Atlas, true); _progressBar.UpdateProgress("import atlas", 0.75f); - //AssetDatabase.Refresh(); AssetDatabase.ImportAsset(atlas_path); return atlas_info.Rects; } @@ -325,8 +312,8 @@ namespace FTEditor.Postprocessors { var asset_atlas = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(asset.Atlas)); clip_asset.Name = symbol.Name; clip_asset.Sprite = asset_atlas; - clip_asset.AssetGUID = asset_guid; clip_asset.FrameRate = data.FrameRate; + clip_asset.AssetGUID = asset_guid; clip_asset.Sequences = LoadClipSequences(asset, data, symbol); EditorUtility.SetDirty(clip_asset); } diff --git a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs index c9663ca..2f3528f 100644 --- a/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs +++ b/Assets/FlashTools/Scripts/Editor/FTEditor/Postprocessors/SwfPostprocessor.cs @@ -14,8 +14,7 @@ using FTSwfTools.SwfTypes; namespace FTEditor.Postprocessors { class SwfPostprocessor : AssetPostprocessor { - static SwfEditorUtils.ProgressBar _progressBar = new SwfEditorUtils.ProgressBar(); - static Queue _assetsForProcess = new Queue(); + static SwfEditorUtils.ProgressBar _progressBar = new SwfEditorUtils.ProgressBar(); static void OnPostprocessAllAssets( string[] imported_assets, @@ -33,23 +32,11 @@ namespace FTEditor.Postprocessors { EditorUtility.DisplayDialog(title, message, "Ok"); } else { foreach ( var swf_path in swf_paths ) { - if ( !_assetsForProcess.Contains(swf_path) ) { - _assetsForProcess.Enqueue(swf_path); - } + EditorApplication.delayCall += () => { + SwfFileProcess(swf_path); + AssetDatabase.SaveAssets(); + }; } - if ( _assetsForProcess.Count > 0 ) { - EditorApplication.update += ProcessAfterImport; - } - } - } - - static void ProcessAfterImport() { - EditorApplication.update -= ProcessAfterImport; - if ( _assetsForProcess.Count > 0 ) { - while ( _assetsForProcess.Count > 0 ) { - SwfFileProcess(_assetsForProcess.Dequeue()); - } - AssetDatabase.SaveAssets(); } } @@ -68,8 +55,10 @@ namespace FTEditor.Postprocessors { static bool SafeLoadSwfAsset(string swf_path, SwfAsset swf_asset) { try { _progressBar.UpdateTitle(Path.GetFileName(swf_path)); - var new_data = LoadSwfAssetData(swf_path); - swf_asset.Data = SwfEditorUtils.CompressAsset(new_data); + var new_data = LoadSwfAssetData(swf_path); + swf_asset.Data = SwfEditorUtils.CompressAsset(new_data); + swf_asset.Atlas = null; + EditorUtility.SetDirty(swf_asset); return true; } catch ( Exception e ) { Debug.LogErrorFormat( diff --git a/Assets/FlashTools/Scripts/Editor/FTEditor/SwfEditorUtils.cs b/Assets/FlashTools/Scripts/Editor/FTEditor/SwfEditorUtils.cs index 8abad30..94a7cd0 100644 --- a/Assets/FlashTools/Scripts/Editor/FTEditor/SwfEditorUtils.cs +++ b/Assets/FlashTools/Scripts/Editor/FTEditor/SwfEditorUtils.cs @@ -157,7 +157,6 @@ namespace FTEditor { asset = ScriptableObject.CreateInstance(); if ( act(asset, true) ) { AssetDatabase.CreateAsset(asset, asset_path); - AssetDatabase.ImportAsset(asset_path); } else { ScriptableObject.DestroyImmediate(asset); }