mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-03-22 12:55:32 +07:00
delete asset by parsing error
This commit is contained in:
@@ -273,6 +273,7 @@ namespace FTEditor.Postprocessors {
|
||||
SwfEditorUtils.LoadOrCreateAsset<SwfClipAsset>(clip_asset_path, (new_clip_asset, created) => {
|
||||
ConfigureClipAsset(new_clip_asset, asset, data, symbol);
|
||||
asset.Clips.Add(new_clip_asset);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +43,21 @@ namespace FTEditor.Postprocessors {
|
||||
swf_asset.Settings = default_settings;
|
||||
swf_asset.Overridden = default_settings;
|
||||
}
|
||||
SafeLoadSwfAsset(swf_path, swf_asset);
|
||||
return SafeLoadSwfAsset(swf_path, swf_asset);
|
||||
});
|
||||
}
|
||||
|
||||
static void SafeLoadSwfAsset(string swf_path, SwfAsset swf_asset) {
|
||||
static bool SafeLoadSwfAsset(string swf_path, SwfAsset swf_asset) {
|
||||
try {
|
||||
var new_data = LoadSwfAssetData(swf_path);
|
||||
swf_asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
||||
swf_asset.Converting = new SwfAsset.ConvertingState();
|
||||
return true;
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat(
|
||||
"<b>[FlashTools]</b> Parsing swf error: {0}",
|
||||
e.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,17 +147,22 @@ namespace FTEditor {
|
||||
return holder;
|
||||
}
|
||||
|
||||
public static T LoadOrCreateAsset<T>(string asset_path, System.Action<T, bool> act) where T : ScriptableObject {
|
||||
public static T LoadOrCreateAsset<T>(string asset_path, System.Func<T, bool, bool> act) where T : ScriptableObject {
|
||||
var asset = AssetDatabase.LoadAssetAtPath<T>(asset_path);
|
||||
if ( asset ) {
|
||||
act(asset, false);
|
||||
EditorUtility.SetDirty(asset);
|
||||
if ( act(asset, false) ) {
|
||||
EditorUtility.SetDirty(asset);
|
||||
AssetDatabase.ImportAsset(asset_path);
|
||||
}
|
||||
} else {
|
||||
asset = ScriptableObject.CreateInstance<T>();
|
||||
act(asset, true);
|
||||
AssetDatabase.CreateAsset(asset, asset_path);
|
||||
if ( act(asset, true) ) {
|
||||
AssetDatabase.CreateAsset(asset, asset_path);
|
||||
AssetDatabase.ImportAsset(asset_path);
|
||||
} else {
|
||||
ScriptableObject.DestroyImmediate(asset);
|
||||
}
|
||||
}
|
||||
AssetDatabase.ImportAsset(asset_path);
|
||||
return asset;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user