mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
remove multiphased import
This commit is contained in:
@@ -85,46 +85,6 @@ NavMeshSettings:
|
|||||||
cellSize: 0.16666667
|
cellSize: 0.16666667
|
||||||
manualCellSize: 0
|
manualCellSize: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
--- !u!1 &41841841
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
serializedVersion: 4
|
|
||||||
m_Component:
|
|
||||||
- 4: {fileID: 41841843}
|
|
||||||
- 114: {fileID: 41841842}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: '[SwfManager]'
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &41841842
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 41841841}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: f455e092ebcb64c3e94de2e2f2f7a614, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!4 &41841843
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 41841841}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 1
|
|
||||||
--- !u!1 &1173114888
|
--- !u!1 &1173114888
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ namespace FTEditor.Editors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ReconvertAsset(SwfAsset asset) {
|
static void ReconvertAsset(SwfAsset asset) {
|
||||||
asset.Converting = new SwfAsset.ConvertingState();
|
|
||||||
AssetDatabase.ImportAsset(
|
AssetDatabase.ImportAsset(
|
||||||
AssetDatabase.GetAssetPath(asset));
|
AssetDatabase.GetAssetPath(asset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ using FTRuntime;
|
|||||||
|
|
||||||
namespace FTEditor.Postprocessors {
|
namespace FTEditor.Postprocessors {
|
||||||
class SwfAssetPostprocessor : AssetPostprocessor {
|
class SwfAssetPostprocessor : AssetPostprocessor {
|
||||||
|
static List<SwfAsset> _assetsForProcess = new List<SwfAsset>();
|
||||||
|
|
||||||
static void OnPostprocessAllAssets(
|
static void OnPostprocessAllAssets(
|
||||||
string[] imported_assets,
|
string[] imported_assets,
|
||||||
string[] deleted_assets,
|
string[] deleted_assets,
|
||||||
@@ -18,25 +20,32 @@ namespace FTEditor.Postprocessors {
|
|||||||
{
|
{
|
||||||
var asset_paths = imported_assets
|
var asset_paths = imported_assets
|
||||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
|
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
|
||||||
foreach ( var asset_path in asset_paths ) {
|
_assetsForProcess = asset_paths
|
||||||
var asset = AssetDatabase.LoadAssetAtPath<SwfAsset>(asset_path);
|
.Select(p => AssetDatabase.LoadAssetAtPath<SwfAsset>(p))
|
||||||
if ( asset ) {
|
.Where(p => !!p)
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
if ( _assetsForProcess.Count > 0 ) {
|
||||||
|
EditorApplication.update += ProcessAfterImport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessAfterImport() {
|
||||||
|
EditorApplication.update -= ProcessAfterImport;
|
||||||
|
var assets = new List<SwfAsset>(_assetsForProcess);
|
||||||
|
_assetsForProcess.Clear();
|
||||||
|
foreach ( var asset in assets ) {
|
||||||
SwfAssetProcess(asset);
|
SwfAssetProcess(asset);
|
||||||
}
|
}
|
||||||
}
|
AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SwfAssetProcess(SwfAsset asset) {
|
static void SwfAssetProcess(SwfAsset asset) {
|
||||||
try {
|
try {
|
||||||
if ( asset.Converting.Stage == 0 ) {
|
|
||||||
var new_data = ConfigureBitmaps(
|
var new_data = ConfigureBitmaps(
|
||||||
asset,
|
asset,
|
||||||
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
|
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
|
||||||
asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
||||||
++asset.Converting.Stage;
|
|
||||||
EditorUtility.SetDirty(asset);
|
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(asset));
|
|
||||||
} else if ( asset.Converting.Stage == 1 ) {
|
|
||||||
asset.Atlas = LoadAssetAtlas(asset);
|
asset.Atlas = LoadAssetAtlas(asset);
|
||||||
if ( asset.Atlas ) {
|
if ( asset.Atlas ) {
|
||||||
ConfigureAtlas(asset);
|
ConfigureAtlas(asset);
|
||||||
@@ -44,10 +53,6 @@ namespace FTEditor.Postprocessors {
|
|||||||
asset,
|
asset,
|
||||||
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
|
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
|
||||||
}
|
}
|
||||||
++asset.Converting.Stage;
|
|
||||||
EditorUtility.SetDirty(asset);
|
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(asset));
|
|
||||||
}
|
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
Debug.LogErrorFormat(
|
Debug.LogErrorFormat(
|
||||||
"<b>[FlashTools]</b> Postprocess swf asset error: {0}",
|
"<b>[FlashTools]</b> Postprocess swf asset error: {0}",
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ using FTSwfTools.SwfTypes;
|
|||||||
|
|
||||||
namespace FTEditor.Postprocessors {
|
namespace FTEditor.Postprocessors {
|
||||||
class SwfPostprocessor : AssetPostprocessor {
|
class SwfPostprocessor : AssetPostprocessor {
|
||||||
|
static List<string> _assetsForProcess = new List<string>();
|
||||||
|
|
||||||
static void OnPostprocessAllAssets(
|
static void OnPostprocessAllAssets(
|
||||||
string[] imported_assets,
|
string[] imported_assets,
|
||||||
string[] deleted_assets,
|
string[] deleted_assets,
|
||||||
@@ -29,10 +31,21 @@ namespace FTEditor.Postprocessors {
|
|||||||
"It means that you can't have more than 5 animation assets in the project.";
|
"It means that you can't have more than 5 animation assets in the project.";
|
||||||
EditorUtility.DisplayDialog(title, message, "Ok");
|
EditorUtility.DisplayDialog(title, message, "Ok");
|
||||||
} else {
|
} else {
|
||||||
|
_assetsForProcess = swf_paths.ToList();
|
||||||
|
if ( _assetsForProcess.Count > 0 ) {
|
||||||
|
EditorApplication.update += ProcessAfterImport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessAfterImport() {
|
||||||
|
EditorApplication.update -= ProcessAfterImport;
|
||||||
|
var swf_paths = new List<string>(_assetsForProcess);
|
||||||
|
_assetsForProcess.Clear();
|
||||||
foreach ( var swf_path in swf_paths ) {
|
foreach ( var swf_path in swf_paths ) {
|
||||||
SwfFileProcess(swf_path);
|
SwfFileProcess(swf_path);
|
||||||
}
|
}
|
||||||
}
|
AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SwfFileProcess(string swf_path) {
|
static void SwfFileProcess(string swf_path) {
|
||||||
@@ -51,7 +64,6 @@ namespace FTEditor.Postprocessors {
|
|||||||
try {
|
try {
|
||||||
var new_data = LoadSwfAssetData(swf_path);
|
var new_data = LoadSwfAssetData(swf_path);
|
||||||
swf_asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
swf_asset.Data = SwfEditorUtils.CompressAsset(new_data);
|
||||||
swf_asset.Converting = new SwfAsset.ConvertingState();
|
|
||||||
return true;
|
return true;
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
Debug.LogErrorFormat(
|
Debug.LogErrorFormat(
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ namespace FTEditor {
|
|||||||
if ( asset ) {
|
if ( asset ) {
|
||||||
if ( act(asset, false) ) {
|
if ( act(asset, false) ) {
|
||||||
EditorUtility.SetDirty(asset);
|
EditorUtility.SetDirty(asset);
|
||||||
AssetDatabase.ImportAsset(asset_path);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
asset = ScriptableObject.CreateInstance<T>();
|
asset = ScriptableObject.CreateInstance<T>();
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace FTRuntime {
|
namespace FTRuntime {
|
||||||
public class SwfAsset : ScriptableObject {
|
public class SwfAsset : ScriptableObject {
|
||||||
[System.Serializable]
|
|
||||||
public struct ConvertingState {
|
|
||||||
public int Stage;
|
|
||||||
}
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public byte[] Data;
|
public byte[] Data;
|
||||||
[SwfReadOnly]
|
[SwfReadOnly]
|
||||||
@@ -18,8 +14,6 @@ namespace FTRuntime {
|
|||||||
public SwfSettingsData Settings;
|
public SwfSettingsData Settings;
|
||||||
[SwfDisplayName("Settings")]
|
[SwfDisplayName("Settings")]
|
||||||
public SwfSettingsData Overridden;
|
public SwfSettingsData Overridden;
|
||||||
[HideInInspector]
|
|
||||||
public ConvertingState Converting;
|
|
||||||
|
|
||||||
void Reset() {
|
void Reset() {
|
||||||
Data = new byte[0];
|
Data = new byte[0];
|
||||||
@@ -27,7 +21,6 @@ namespace FTRuntime {
|
|||||||
Clips = new List<SwfClipAsset>();
|
Clips = new List<SwfClipAsset>();
|
||||||
Settings = SwfSettingsData.identity;
|
Settings = SwfSettingsData.identity;
|
||||||
Overridden = SwfSettingsData.identity;
|
Overridden = SwfSettingsData.identity;
|
||||||
Converting = new ConvertingState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user