mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-13 11:39:54 +07:00
Fix preview shutdown warning
This commit is contained in:
@@ -8,9 +8,9 @@ using FTRuntime;
|
||||
namespace FTEditor.Editors {
|
||||
[CustomPreview(typeof(SwfClipAsset))]
|
||||
class SwfClipAssetPreview : ObjectPreview {
|
||||
int _sequence = 0;
|
||||
static MaterialPropertyBlock _matPropBlock = null;
|
||||
static PreviewRenderUtility _previewUtils = null;
|
||||
int _sequence = 0;
|
||||
MaterialPropertyBlock _matPropBlock = null;
|
||||
PreviewRenderUtility _previewUtils = null;
|
||||
|
||||
Sprite targetSprite {
|
||||
get {
|
||||
@@ -142,6 +142,11 @@ namespace FTEditor.Editors {
|
||||
: 0;
|
||||
}
|
||||
|
||||
public void Shutdown() {
|
||||
_matPropBlock.Clear();
|
||||
_previewUtils.Cleanup();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace FTEditor.Editors {
|
||||
}
|
||||
|
||||
void SetupPreviews() {
|
||||
_previews.Clear();
|
||||
ShutdownPreviews();
|
||||
foreach ( var clip in _clips.Where(p => !!p.clip) ) {
|
||||
var preview = new SwfClipAssetPreview();
|
||||
preview.Initialize(new Object[]{clip.clip});
|
||||
@@ -139,18 +139,29 @@ namespace FTEditor.Editors {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
void ShutdownPreviews() {
|
||||
foreach ( var p in _previews ) {
|
||||
p.Value.Shutdown();
|
||||
}
|
||||
_previews.Clear();
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void OnEnable() {
|
||||
_clips = targets.OfType<SwfClip>().ToList();
|
||||
SetupPreviews();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
void OnDisable() {
|
||||
ShutdownPreviews();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
DrawDefaultInspector();
|
||||
DrawSequence();
|
||||
|
||||
Reference in New Issue
Block a user