#if UNITY_EDITOR using UnityEngine; using UnityEditor; using UnityEngine.Networking; 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); // } Debug.Log(upperPath); if (upperPath.Contains("ASSETS/_DDD/_RAW/SPRITES/")) { AssetPostprocessorSprite.OnPreprocessTexture(importer); } } public static void OnPostprocessAllAssets(string[] importedAssets, string[] deleteAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int i = 0; i < movedAssets.Length; i++) { string fromPath = movedFromAssetPaths[i]; string toPath = movedAssets[i]; // 특정 폴더일 때만 작동 if (toPath.StartsWith("Assets/_DDD/_Raw/Sprites/")) { if (AssetDatabase.LoadAssetAtPath(toPath) == null) { Debug.Log($"에셋 이동 감지: {fromPath} → {toPath}"); // 여기서 임포트 강제 재실행 AssetDatabase.ImportAsset(toPath, ImportAssetOptions.ForceUpdate); } } } 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