mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
reimport assets fix
This commit is contained in:
@@ -61,11 +61,6 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
static void ReconvertAnimationAsset(SwfAnimationAsset asset) {
|
||||
if ( asset && asset.Atlas ) {
|
||||
AssetDatabase.DeleteAsset(
|
||||
AssetDatabase.GetAssetPath(asset.Atlas));
|
||||
asset.Atlas = null;
|
||||
}
|
||||
AssetDatabase.ImportAsset(
|
||||
GetSwfPath(asset),
|
||||
ImportAssetOptions.ForceUpdate);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace FlashTools.Internal {
|
||||
EditorUtility.SetDirty(asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
ConfigureAssetAnimations(asset);
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat(
|
||||
"Postprocess swf animation asset error: {0}",
|
||||
@@ -309,5 +310,18 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// ConfigureAssetAnimations
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
static void ConfigureAssetAnimations(SwfAnimationAsset asset) {
|
||||
var animations = GameObject.FindObjectsOfType<SwfAnimation>();
|
||||
foreach ( var animation in animations ) {
|
||||
animation.UpdateAllProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,11 @@ namespace FlashTools.Internal {
|
||||
|
||||
static bool LoadDataFromSwfFile(string swf_asset, SwfAnimationAsset asset) {
|
||||
try {
|
||||
if ( asset.Atlas ) {
|
||||
AssetDatabase.DeleteAsset(
|
||||
AssetDatabase.GetAssetPath(asset.Atlas));
|
||||
asset.Atlas = null;
|
||||
}
|
||||
asset.Data = LoadAnimationDataFromSwfDecoder(
|
||||
swf_asset,
|
||||
asset,
|
||||
|
||||
@@ -110,34 +110,13 @@ namespace FlashTools {
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void UpdateAllProperties() {
|
||||
public void UpdateAllProperties() {
|
||||
asset = _asset;
|
||||
currentFrame = _currentFrame;
|
||||
sortingLayer = _sortingLayer;
|
||||
sortingOrder = _sortingOrder;
|
||||
}
|
||||
|
||||
void UpdateMaterialPropertyBlock() {
|
||||
if ( _matPropBlock != null ) {
|
||||
var atlas = asset && asset.Atlas ? asset.Atlas : null;
|
||||
if ( atlas ) {
|
||||
_matPropBlock.SetTexture("_MainTex", atlas);
|
||||
} else {
|
||||
_matPropBlock.Clear();
|
||||
}
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.SetPropertyBlock(_matPropBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeSortingProperties() {
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.sortingOrder = sortingOrder;
|
||||
_meshRenderer.sortingLayerName = sortingLayer;
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeAsset() {
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.enabled = !!asset;
|
||||
@@ -153,12 +132,31 @@ namespace FlashTools {
|
||||
UpdateCurrentMesh();
|
||||
}
|
||||
|
||||
void UpdateCurrentMesh() {
|
||||
var baked_frame = GetCurrentBakedFrame();
|
||||
if ( _meshFilter ) {
|
||||
_meshFilter.sharedMesh = baked_frame.Mesh;
|
||||
}
|
||||
void ChangeSortingProperties() {
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.sortingOrder = sortingOrder;
|
||||
_meshRenderer.sortingLayerName = sortingLayer;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateMaterialPropertyBlock() {
|
||||
if ( _meshRenderer ) {
|
||||
if ( _matPropBlock == null ) {
|
||||
_matPropBlock = new MaterialPropertyBlock();
|
||||
}
|
||||
_meshRenderer.GetPropertyBlock(_matPropBlock);
|
||||
var atlas = asset && asset.Atlas ? asset.Atlas : null;
|
||||
if ( atlas ) {
|
||||
_matPropBlock.SetTexture("_MainTex", atlas);
|
||||
}
|
||||
_meshRenderer.SetPropertyBlock(_matPropBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCurrentMesh() {
|
||||
if ( _meshFilter && _meshRenderer ) {
|
||||
var baked_frame = GetCurrentBakedFrame();
|
||||
_meshFilter.sharedMesh = baked_frame.Mesh;
|
||||
_meshRenderer.sharedMaterials = baked_frame.Materials;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user