From 8b2db5f5d4b93fbaf78244f6eadc8286fd00e66d Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Fri, 4 Jul 2025 16:21:11 +0900 Subject: [PATCH] =?UTF-8?q?Editor=20=EC=A0=84=EC=B9=98=EB=A6=AC=EA=B8=B0?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssetPostProcessors.cs | 79 +++++++++++++++++++ .../AssetPostProcessors.cs.meta | 2 + 2 files changed, 81 insertions(+) create mode 100644 Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs create mode 100644 Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs.meta diff --git a/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs b/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs new file mode 100644 index 000000000..9475a2cfc --- /dev/null +++ b/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs @@ -0,0 +1,79 @@ +#if UNITY_EDITOR +using UnityEngine; +using UnityEditor; + +namespace DDD +{ + public class AssetPostProcessors : AssetPostprocessor + { + private void OnPreprocessTexture() + { + var importer = assetImporter as TextureImporter; + + var upperPath = importer.assetPath.ToUpper(); + + // if (upperPath.Contains("ASSETS/RAW/Units/")) + // { + // AssetPostprocessorModel.OnPreprocessTexture(importer); + // } + + if (upperPath.Contains("ASSETS/_DATAS/RAW/SPRITES/")) + { + AssetPostprocessorSprite.OnPreprocessTexture(importer); + } + } + + public static void OnPostprocessAllAssets(string[] importedAssets, string[] deleteAssets, string[] movedAssets, string[] movedFromAssetPaths) + { + foreach (var path in deleteAssets) + { + PostRemove(path); + } + + var index = 0; + foreach (var path in movedFromAssetPaths) + { + PostRemove(path, movedAssets[index]); + ++index; + } + + foreach (var path in movedAssets) + { + PostAdd(path); + } + + foreach (var path in importedAssets) + { + PostAdd(path); + } + + AssetPostprocessorSprite.BuildTarget(); + AssetPostprocessorSprite.BuildTarget(); + } + + private static void PostRemove(string path, string movePath = "") + { + try + { + AssetPostprocessorSprite.OnRemove(path, movePath); + } + catch (System.Exception e) + { + Debug.LogError("Can't remove " + path + "\n" + e); + } + } + + private static void PostAdd(string path) + { + try + { + AssetPostprocessorSprite.OnAdd(path); + } + catch (System.Exception e) + { + Debug.LogError("Can't import " + path + "\n" + e); + } + } + } +} +#endif \ No newline at end of file diff --git a/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs.meta b/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs.meta new file mode 100644 index 000000000..64b750428 --- /dev/null +++ b/Assets/_Datas/02.Scripts/AssetPostprocessors/AssetPostProcessors.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0027aa4e810904745aab9cda1a5e11be \ No newline at end of file