sprites reimport 오류 수정
This commit is contained in:
parent
727b7e2f91
commit
33eb9439f5
@ -203,6 +203,13 @@ public static void CreateAtlas(string path, string destPath)
|
||||
|
||||
if (objects.Count == 0) return;
|
||||
|
||||
// Validate destination path extension
|
||||
if (!destPath.EndsWith(ExtenstionConstants.SpriteAtlasExtenstionLower, System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Debug.LogWarning($"[SpriteAtlas] destPath must end with .spriteatlas : {destPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.MakeFolderFromFilePath(destPath);
|
||||
var atlas = new SpriteAtlasAsset();
|
||||
|
||||
@ -216,9 +223,17 @@ public static void CreateAtlas(string path, string destPath)
|
||||
atlas.Add(objects.ToArray());
|
||||
|
||||
SpriteAtlasAsset.Save(atlas, destPath);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||
// Ensure importer is created/applied synchronously before accessing it
|
||||
AssetDatabase.ImportAsset(destPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
|
||||
|
||||
var sai = AssetImporter.GetAtPath(destPath) as SpriteAtlasImporter;
|
||||
if (sai == null)
|
||||
{
|
||||
Debug.LogWarning($"[SpriteAtlas] Importer not ready for '{destPath}'. Skipping settings this pass.");
|
||||
return;
|
||||
}
|
||||
|
||||
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||
{
|
||||
enableRotation = false,
|
||||
@ -235,8 +250,11 @@ public static void CreateAtlas(string path, string destPath)
|
||||
generateMipMaps = false
|
||||
};
|
||||
|
||||
// 저장 후 설정 반영을 위해 동기 임포트, 그리고 즉시 패킹 수행
|
||||
// Persist settings and reimport synchronously to apply them
|
||||
AssetDatabase.WriteImportSettingsIfDirty(destPath);
|
||||
AssetDatabase.ImportAsset(destPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
|
||||
|
||||
// Finally, pack the atlas for the active build target
|
||||
var packedAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||
if (packedAtlas != null)
|
||||
{
|
||||
@ -253,10 +271,22 @@ public static void CreateSingleAtlas(string path, string destPath)
|
||||
AssetDatabase.DeleteAsset(destPath);
|
||||
}
|
||||
|
||||
// Validate destination path extension
|
||||
if (!destPath.EndsWith(ExtenstionConstants.SpriteAtlasExtenstionLower, System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Debug.LogWarning($"[SpriteAtlas] destPath must end with .spriteatlas : {destPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.MakeFolderFromFilePath(destPath);
|
||||
var atlas = new SpriteAtlasAsset();
|
||||
|
||||
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||||
if (sprite == null)
|
||||
{
|
||||
Debug.LogWarning($"[SpriteAtlas] Source sprite not found at '{path}'. Skipping atlas: '{destPath}'");
|
||||
return;
|
||||
}
|
||||
atlas.Add(new Object[] { sprite });
|
||||
|
||||
var spriteAtlasComponents = new List<IPostProcessorSpriteAtlas>();
|
||||
@ -267,9 +297,17 @@ public static void CreateSingleAtlas(string path, string destPath)
|
||||
}
|
||||
|
||||
SpriteAtlasAsset.Save(atlas, destPath);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
var sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(destPath);
|
||||
// Ensure importer is created/applied synchronously before accessing it
|
||||
AssetDatabase.ImportAsset(destPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
|
||||
|
||||
var sai = AssetImporter.GetAtPath(destPath) as SpriteAtlasImporter;
|
||||
if (sai == null)
|
||||
{
|
||||
Debug.LogWarning($"[SpriteAtlas] Importer not ready for '{destPath}'. Skipping settings this pass.");
|
||||
return;
|
||||
}
|
||||
|
||||
sai.packingSettings = new SpriteAtlasPackingSettings
|
||||
{
|
||||
enableRotation = false,
|
||||
@ -286,8 +324,11 @@ public static void CreateSingleAtlas(string path, string destPath)
|
||||
generateMipMaps = false
|
||||
};
|
||||
|
||||
// 저장 후 설정 반영을 위해 동기 임포트, 그리고 즉시 패킹 수행
|
||||
// Persist settings and reimport synchronously to apply them
|
||||
AssetDatabase.WriteImportSettingsIfDirty(destPath);
|
||||
AssetDatabase.ImportAsset(destPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
|
||||
|
||||
// Finally, pack the atlas for the active build target
|
||||
var packedAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(destPath);
|
||||
if (packedAtlas != null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user