delete asset by parsing error

This commit is contained in:
2016-10-15 02:17:38 +07:00
parent f04ffd6d76
commit 61c053af15
3 changed files with 16 additions and 8 deletions

View File

@@ -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;
});
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}