mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-15 12:29:49 +07:00
Add warning notes about outdated assets
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
###### Version 1.3.15
|
###### Version 1.3.15
|
||||||
* Add bitmap trimming
|
* Add bitmap trimming
|
||||||
* Fix preview leaks in the Editor mode
|
* Fix preview leaks in the Editor mode
|
||||||
|
* Add warning notes about outdated assets
|
||||||
|
|
||||||
###### Version 1.3.14
|
###### Version 1.3.14
|
||||||
* Fix 2018.3.2f1 compilation
|
* Fix 2018.3.2f1 compilation
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ using FTRuntime;
|
|||||||
namespace FTEditor.Editors {
|
namespace FTEditor.Editors {
|
||||||
[CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects]
|
[CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects]
|
||||||
class SwfAssetEditor : Editor {
|
class SwfAssetEditor : Editor {
|
||||||
List<SwfAsset> _assets = new List<SwfAsset>();
|
bool _outdated = false;
|
||||||
|
List<SwfAsset> _assets = new List<SwfAsset>();
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -129,6 +130,12 @@ namespace FTEditor.Editors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawGUINotes() {
|
||||||
|
if ( _outdated ) {
|
||||||
|
SwfEditorUtils.DrawOutdatedGUINotes("SwfAsset", _assets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
@@ -137,6 +144,7 @@ namespace FTEditor.Editors {
|
|||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
_assets = targets.OfType<SwfAsset>().ToList();
|
_assets = targets.OfType<SwfAsset>().ToList();
|
||||||
|
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_assets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable() {
|
void OnDisable() {
|
||||||
@@ -147,6 +155,7 @@ namespace FTEditor.Editors {
|
|||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
DrawDefaultInspector();
|
DrawDefaultInspector();
|
||||||
DrawGUISettingsControls();
|
DrawGUISettingsControls();
|
||||||
|
DrawGUINotes();
|
||||||
if ( GUI.changed ) {
|
if ( GUI.changed ) {
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ using FTRuntime;
|
|||||||
namespace FTEditor.Editors {
|
namespace FTEditor.Editors {
|
||||||
[CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects]
|
[CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects]
|
||||||
class SwfClipAssetEditor : Editor {
|
class SwfClipAssetEditor : Editor {
|
||||||
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
|
bool _outdated = false;
|
||||||
SwfClipAssetPreview _preview = null;
|
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
|
||||||
|
SwfClipAssetPreview _preview = null;
|
||||||
|
|
||||||
static string GetClipPath(SwfClipAsset clip) {
|
static string GetClipPath(SwfClipAsset clip) {
|
||||||
return clip
|
return clip
|
||||||
@@ -158,11 +159,10 @@ namespace FTEditor.Editors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawGUINotes() {
|
void DrawGUINotes() {
|
||||||
EditorGUILayout.Separator();
|
SwfEditorUtils.DrawMasksGUINotes();
|
||||||
EditorGUILayout.HelpBox(
|
if ( _outdated ) {
|
||||||
"Masks and blends of animation may not be displayed correctly in the preview window. " +
|
SwfEditorUtils.DrawOutdatedGUINotes("SwfClipAsset", _clips);
|
||||||
"Instance animation to the scene, to see how it will look like the animation in the game.",
|
}
|
||||||
MessageType.Info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -193,6 +193,7 @@ namespace FTEditor.Editors {
|
|||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
_clips = targets.OfType<SwfClipAsset>().ToList();
|
_clips = targets.OfType<SwfClipAsset>().ToList();
|
||||||
|
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_clips);
|
||||||
SetupPreviews();
|
SetupPreviews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using FTRuntime;
|
|||||||
namespace FTEditor.Editors {
|
namespace FTEditor.Editors {
|
||||||
[CustomEditor(typeof(SwfClip)), CanEditMultipleObjects]
|
[CustomEditor(typeof(SwfClip)), CanEditMultipleObjects]
|
||||||
class SwfClipEditor : Editor {
|
class SwfClipEditor : Editor {
|
||||||
|
bool _outdated = false;
|
||||||
List<SwfClip> _clips = new List<SwfClip>();
|
List<SwfClip> _clips = new List<SwfClip>();
|
||||||
Dictionary<SwfClip, SwfClipAssetPreview> _previews = new Dictionary<SwfClip, SwfClipAssetPreview>();
|
Dictionary<SwfClip, SwfClipAssetPreview> _previews = new Dictionary<SwfClip, SwfClipAssetPreview>();
|
||||||
|
|
||||||
@@ -71,6 +72,12 @@ namespace FTEditor.Editors {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawGUINotes() {
|
||||||
|
if ( _outdated ) {
|
||||||
|
SwfEditorUtils.DrawOutdatedGUINotes("SwfClip", _clips);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DrawSequence() {
|
void DrawSequence() {
|
||||||
var all_sequences = GetAllSequences(true);
|
var all_sequences = GetAllSequences(true);
|
||||||
if ( all_sequences.Count > 0 ) {
|
if ( all_sequences.Count > 0 ) {
|
||||||
@@ -157,6 +164,7 @@ namespace FTEditor.Editors {
|
|||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
_clips = targets.OfType<SwfClip>().ToList();
|
_clips = targets.OfType<SwfClip>().ToList();
|
||||||
|
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_clips);
|
||||||
SetupPreviews();
|
SetupPreviews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +175,7 @@ namespace FTEditor.Editors {
|
|||||||
|
|
||||||
public override void OnInspectorGUI() {
|
public override void OnInspectorGUI() {
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
DrawGUINotes();
|
||||||
DrawDefaultInspector();
|
DrawDefaultInspector();
|
||||||
DrawSequence();
|
DrawSequence();
|
||||||
DrawCurrentFrame();
|
DrawCurrentFrame();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using UnityEditor;
|
|||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
|
||||||
@@ -307,6 +308,13 @@ namespace FTEditor {
|
|||||||
GetFileHash(path), SwfVersion.AsString);
|
GetFileHash(path), SwfVersion.AsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetVersionFromFileHashWithVersion(string hash) {
|
||||||
|
var index = hash.LastIndexOf('=');
|
||||||
|
return index != -1
|
||||||
|
? hash.Substring(index + 1)
|
||||||
|
: string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
static string GetFileHash(string path) {
|
static string GetFileHash(string path) {
|
||||||
try {
|
try {
|
||||||
using ( var sha256 = SHA256.Create() ) {
|
using ( var sha256 = SHA256.Create() ) {
|
||||||
@@ -321,6 +329,117 @@ namespace FTEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Outdated assets
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(SwfClip clip) {
|
||||||
|
return clip
|
||||||
|
&& CheckForOutdatedAsset(clip.clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(SwfClipAsset clip_asset) {
|
||||||
|
return clip_asset
|
||||||
|
&& CheckForOutdatedAsset(AssetDatabase.LoadAssetAtPath<SwfAsset>(
|
||||||
|
AssetDatabase.GUIDToAssetPath(clip_asset.AssetGUID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(SwfAsset asset) {
|
||||||
|
return asset
|
||||||
|
&& GetVersionFromFileHashWithVersion(asset.Hash) != SwfVersion.AsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(IEnumerable<SwfClip> clips) {
|
||||||
|
var iter = clips.GetEnumerator();
|
||||||
|
while ( iter.MoveNext() ) {
|
||||||
|
if ( CheckForOutdatedAsset(iter.Current) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(IEnumerable<SwfClipAsset> clip_assets) {
|
||||||
|
var iter = clip_assets.GetEnumerator();
|
||||||
|
while ( iter.MoveNext() ) {
|
||||||
|
if ( CheckForOutdatedAsset(iter.Current) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOutdatedAsset(IEnumerable<SwfAsset> assets) {
|
||||||
|
var iter = assets.GetEnumerator();
|
||||||
|
while ( iter.MoveNext() ) {
|
||||||
|
if ( CheckForOutdatedAsset(iter.Current) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GUI notes
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
public static void DrawMasksGUINotes() {
|
||||||
|
EditorGUILayout.Separator();
|
||||||
|
EditorGUILayout.HelpBox(
|
||||||
|
"Masks and blends of animation may not be displayed correctly in the preview window. " +
|
||||||
|
"Instance animation to the scene, to see how it will look like the animation in the game.",
|
||||||
|
MessageType.Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawOutdatedGUINotes(string target, IEnumerable<SwfClip> clips) {
|
||||||
|
DrawOutdatedGUINotes(target, clips
|
||||||
|
.Select(p => p ? p.clip : null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawOutdatedGUINotes(string target, IEnumerable<SwfClipAsset> clips) {
|
||||||
|
DrawOutdatedGUINotes(target, clips
|
||||||
|
.Select(p => {
|
||||||
|
return p
|
||||||
|
? AssetDatabase.LoadAssetAtPath<SwfAsset>(AssetDatabase.GUIDToAssetPath(p.AssetGUID))
|
||||||
|
: null;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawOutdatedGUINotes(string target, IEnumerable<SwfAsset> assets) {
|
||||||
|
var asset_count = assets.Count(p => p);
|
||||||
|
if ( asset_count == 1 ) {
|
||||||
|
var asset = assets.FirstOrDefault(p => p);
|
||||||
|
if ( asset ) {
|
||||||
|
var asset_version = GetVersionFromFileHashWithVersion(asset.Hash);
|
||||||
|
if ( asset_version != SwfVersion.AsString ) {
|
||||||
|
EditorGUILayout.Separator();
|
||||||
|
EditorGUILayout.HelpBox(string.Format(
|
||||||
|
"The {0} was created in the {1} version of Flash Animation Toolset, and it's outdated.\n" +
|
||||||
|
"Please, reimport the source .swf file. It's may be essential to correctness working.\n" +
|
||||||
|
"You can do it in Tools/FlashTools menu.",
|
||||||
|
target, asset_version),
|
||||||
|
MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( asset_count > 1 ) {
|
||||||
|
var any_outdated = assets
|
||||||
|
.Any(p => GetVersionFromFileHashWithVersion(p.Hash) != SwfVersion.AsString);
|
||||||
|
if ( any_outdated ) {
|
||||||
|
EditorGUILayout.Separator();
|
||||||
|
EditorGUILayout.HelpBox(string.Format(
|
||||||
|
"Some {0} is outdated.\n" +
|
||||||
|
"Please, reimport the source .swf files. It's may be essential to correctness working.\n" +
|
||||||
|
"You can do it in Tools/FlashTools menu.",
|
||||||
|
target),
|
||||||
|
MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Menu
|
// Menu
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ UNITY_HALF_TEXEL_OFFSET
|
|||||||
**** DONE Утечка превью в редакторе
|
**** DONE Утечка превью в редакторе
|
||||||
*** Улучшения
|
*** Улучшения
|
||||||
**** TODO Выводить в лог успешную конвертацию с контекстом
|
**** TODO Выводить в лог успешную конвертацию с контекстом
|
||||||
**** TODO Добавить версию в SwfAsset
|
**** DONE Предупреждения о устаревших ассетах
|
||||||
**** TODO Опциональный тримминг
|
**** TODO Опциональный тримминг
|
||||||
**** DONE Триммить изображения из swf (adou.fla)
|
**** DONE Триммить изображения из swf (adou.fla)
|
||||||
** DONE Версия 1.3.14
|
** DONE Версия 1.3.14
|
||||||
|
|||||||
Reference in New Issue
Block a user