mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-13 11:39:54 +07:00
Add warning notes about outdated assets
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
###### Version 1.3.15
|
||||
* Add bitmap trimming
|
||||
* Fix preview leaks in the Editor mode
|
||||
* Add warning notes about outdated assets
|
||||
|
||||
###### Version 1.3.14
|
||||
* Fix 2018.3.2f1 compilation
|
||||
|
||||
@@ -10,7 +10,8 @@ using FTRuntime;
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects]
|
||||
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
|
||||
@@ -137,6 +144,7 @@ namespace FTEditor.Editors {
|
||||
|
||||
void OnEnable() {
|
||||
_assets = targets.OfType<SwfAsset>().ToList();
|
||||
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_assets);
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
@@ -147,6 +155,7 @@ namespace FTEditor.Editors {
|
||||
serializedObject.Update();
|
||||
DrawDefaultInspector();
|
||||
DrawGUISettingsControls();
|
||||
DrawGUINotes();
|
||||
if ( GUI.changed ) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ using FTRuntime;
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects]
|
||||
class SwfClipAssetEditor : Editor {
|
||||
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
|
||||
SwfClipAssetPreview _preview = null;
|
||||
bool _outdated = false;
|
||||
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
|
||||
SwfClipAssetPreview _preview = null;
|
||||
|
||||
static string GetClipPath(SwfClipAsset clip) {
|
||||
return clip
|
||||
@@ -158,11 +159,10 @@ namespace FTEditor.Editors {
|
||||
}
|
||||
|
||||
void DrawGUINotes() {
|
||||
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);
|
||||
SwfEditorUtils.DrawMasksGUINotes();
|
||||
if ( _outdated ) {
|
||||
SwfEditorUtils.DrawOutdatedGUINotes("SwfClipAsset", _clips);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -193,6 +193,7 @@ namespace FTEditor.Editors {
|
||||
|
||||
void OnEnable() {
|
||||
_clips = targets.OfType<SwfClipAsset>().ToList();
|
||||
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_clips);
|
||||
SetupPreviews();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using FTRuntime;
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfClip)), CanEditMultipleObjects]
|
||||
class SwfClipEditor : Editor {
|
||||
bool _outdated = false;
|
||||
List<SwfClip> _clips = new List<SwfClip>();
|
||||
Dictionary<SwfClip, SwfClipAssetPreview> _previews = new Dictionary<SwfClip, SwfClipAssetPreview>();
|
||||
|
||||
@@ -71,6 +72,12 @@ namespace FTEditor.Editors {
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawGUINotes() {
|
||||
if ( _outdated ) {
|
||||
SwfEditorUtils.DrawOutdatedGUINotes("SwfClip", _clips);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSequence() {
|
||||
var all_sequences = GetAllSequences(true);
|
||||
if ( all_sequences.Count > 0 ) {
|
||||
@@ -157,6 +164,7 @@ namespace FTEditor.Editors {
|
||||
|
||||
void OnEnable() {
|
||||
_clips = targets.OfType<SwfClip>().ToList();
|
||||
_outdated = SwfEditorUtils.CheckForOutdatedAsset(_clips);
|
||||
SetupPreviews();
|
||||
}
|
||||
|
||||
@@ -167,6 +175,7 @@ namespace FTEditor.Editors {
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
DrawGUINotes();
|
||||
DrawDefaultInspector();
|
||||
DrawSequence();
|
||||
DrawCurrentFrame();
|
||||
|
||||
@@ -3,6 +3,7 @@ using UnityEditor;
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
@@ -307,6 +308,13 @@ namespace FTEditor {
|
||||
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) {
|
||||
try {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user