mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
add version to swf hash
This commit is contained in:
@@ -42,7 +42,7 @@ namespace FTEditor.Postprocessors {
|
||||
}
|
||||
|
||||
static void SwfFileProcess(string swf_path) {
|
||||
var swf_hash = SwfEditorUtils.GetFileHash(swf_path);
|
||||
var swf_hash = SwfEditorUtils.GetFileHashWithVersion(swf_path);
|
||||
var swf_asset_path = Path.ChangeExtension(swf_path, ".asset");
|
||||
SwfEditorUtils.LoadOrCreateAsset<SwfAsset>(swf_asset_path, (swf_asset, created) => {
|
||||
if ( !string.IsNullOrEmpty(swf_asset.Hash) && swf_asset.Hash == swf_hash ) {
|
||||
|
||||
@@ -266,12 +266,20 @@ namespace FTEditor {
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
public static string GetFileHash(string path) {
|
||||
public static string GetFileHashWithVersion(string path) {
|
||||
return string.Format(
|
||||
"{0}={1}",
|
||||
GetFileHash(path), SwfVersion.AsString);
|
||||
}
|
||||
|
||||
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();
|
||||
return
|
||||
System.Convert.ToBase64String(hash_bytes) +
|
||||
file_bytes.LongLength.ToString();
|
||||
}
|
||||
} catch ( System.Exception ) {
|
||||
return string.Empty;
|
||||
|
||||
15
Assets/FlashTools/Scripts/FTRuntime/SwfVersion.cs
Normal file
15
Assets/FlashTools/Scripts/FTRuntime/SwfVersion.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace FTRuntime {
|
||||
public static class SwfVersion {
|
||||
public const int Major = 1;
|
||||
public const int Minor = 3;
|
||||
public const int Revision = 8;
|
||||
|
||||
public static string AsString {
|
||||
get {
|
||||
return string.Format(
|
||||
"{0}.{1}.{2}",
|
||||
Major, Minor, Revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/FlashTools/Scripts/FTRuntime/SwfVersion.cs.meta
Normal file
12
Assets/FlashTools/Scripts/FTRuntime/SwfVersion.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9326b7a46761449f7bbb3d857cffacec
|
||||
timeCreated: 1495899500
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user