mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
Remove excess animation reimports
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* Add shape tween warning
|
||||
* Add SwfClip bounds functions (currentLocalBounds, currentWorldBounds)
|
||||
* Remove excess "if" instruction from shaders
|
||||
* Remove excess animation reimports
|
||||
|
||||
###### Version 1.3.7
|
||||
* Fix multiple import
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -42,22 +42,26 @@ namespace FTEditor.Postprocessors {
|
||||
}
|
||||
|
||||
static void SwfFileProcess(string swf_path) {
|
||||
var swf_hash = SwfEditorUtils.GetFileHash(swf_path);
|
||||
var swf_asset_path = Path.ChangeExtension(swf_path, ".asset");
|
||||
SwfEditorUtils.LoadOrCreateAsset<SwfAsset>(swf_asset_path, (swf_asset, created) => {
|
||||
if ( created ) {
|
||||
if ( !string.IsNullOrEmpty(swf_asset.Hash) && swf_asset.Hash == swf_hash ) {
|
||||
return true;
|
||||
} else if ( created ) {
|
||||
var default_settings = SwfEditorUtils.GetSettingsHolder().Settings;
|
||||
swf_asset.Settings = default_settings;
|
||||
swf_asset.Overridden = default_settings;
|
||||
}
|
||||
return SafeLoadSwfAsset(swf_path, swf_asset);
|
||||
return SafeLoadSwfAsset(swf_path, swf_hash, swf_asset);
|
||||
});
|
||||
}
|
||||
|
||||
static bool SafeLoadSwfAsset(string swf_path, SwfAsset swf_asset) {
|
||||
static bool SafeLoadSwfAsset(string swf_path, string swf_hash, SwfAsset swf_asset) {
|
||||
try {
|
||||
_progressBar.UpdateTitle(Path.GetFileName(swf_path));
|
||||
var new_data = LoadSwfAssetData(swf_path);
|
||||
swf_asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
||||
swf_asset.Hash = swf_hash;
|
||||
swf_asset.Atlas = null;
|
||||
EditorUtility.SetDirty(swf_asset);
|
||||
return true;
|
||||
|
||||
@@ -4,6 +4,7 @@ using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
using Ionic.Zlib;
|
||||
@@ -259,6 +260,24 @@ namespace FTEditor {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// FileHash
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
public static string GetFileHash(string path) {
|
||||
try {
|
||||
using ( var sha256 = SHA256.Create() ) {
|
||||
var file_bytes = File.ReadAllBytes(path);
|
||||
var hash_bytes = sha256.ComputeHash(file_bytes);
|
||||
return System.Convert.ToBase64String(hash_bytes) + file_bytes.LongLength.ToString();
|
||||
}
|
||||
} catch ( System.Exception ) {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Menu
|
||||
@@ -286,6 +305,17 @@ namespace FTEditor {
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/FlashTools/Reconvert all swf assets")]
|
||||
static void Tools_FlashTools_ReconvertAllSwfAssets() {
|
||||
Tools_FlashTools_ReimportAllSwfFiles();
|
||||
var swf_assets = GetAllSwfAssets();
|
||||
foreach ( var swf_asset in swf_assets ) {
|
||||
swf_asset.Atlas = null;
|
||||
EditorUtility.SetDirty(swf_asset);
|
||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(swf_asset));
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/FlashTools/Pregenerate all materials")]
|
||||
static void PregenerateAllMaterials() {
|
||||
var blend_modes = System.Enum.GetValues(typeof(SwfBlendModeData.Types));
|
||||
@@ -299,6 +329,10 @@ namespace FTEditor {
|
||||
SwfMaterialCache.GetDecrMaskMaterial();
|
||||
}
|
||||
|
||||
static SwfAsset[] GetAllSwfAssets() {
|
||||
return SwfEditorUtils.LoadAllAssetsDBByFilter<SwfAsset>("t:SwfAsset");
|
||||
}
|
||||
|
||||
static string[] GetAllSwfFilePaths() {
|
||||
return AssetDatabase.GetAllAssetPaths()
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"))
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace FTRuntime {
|
||||
public class SwfAsset : ScriptableObject {
|
||||
[HideInInspector]
|
||||
public byte[] Data;
|
||||
[HideInInspector]
|
||||
public string Hash;
|
||||
[SwfReadOnly]
|
||||
public Texture2D Atlas;
|
||||
[HideInInspector]
|
||||
@@ -15,6 +17,7 @@ namespace FTRuntime {
|
||||
|
||||
void Reset() {
|
||||
Data = new byte[0];
|
||||
Hash = string.Empty;
|
||||
Atlas = null;
|
||||
Settings = SwfSettingsData.identity;
|
||||
Overridden = SwfSettingsData.identity;
|
||||
|
||||
@@ -56,7 +56,7 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3
|
||||
**** TODO Интеграция с автобилдами
|
||||
**** DONE Избавиться от условия на _ExternalAlpha
|
||||
**** DONE Добавить возможность брать bounds у клипа
|
||||
**** TODO Не реимпортить на каждый чих анимацию, хранить хэш
|
||||
**** DONE Не реимпортить на каждый чих анимацию, хранить хэш
|
||||
dipyalov: фишка в том, что swf обновился, но и собранные ассеты-то тоже обновились
|
||||
**** DONE Элемент может быть залокан (element.locked)
|
||||
**** DONE Возможно не стоит преобразовывать группы в символы
|
||||
|
||||
Reference in New Issue
Block a user