.sprites 가 계속 Unix 로 바뀌에서 Git 리스트에 뜨는 버그 수정.
Assets / Editor 하위에 .cs 파일 만들어서 추가하면 됨.
using UnityEngine;
using UnityEditor;
using System.IO;
class ProjectAssetPostprocessor : AssetPostprocessor
{
private void OnPreprocessAsset()
{
if(assetImporter != null && assetImporter.assetPath != "" && assetImporter.assetPath != null)
{
string extension = Path.GetExtension(assetImporter.assetPath);
if (extension.IndexOf(".spriteatlas") != -1)
{
const string Windows = "\r\n";
const string Unix = "\n";
const string Mac = "\r";
string targetEndingType = Windows;
string ending = Windows;
if (targetEndingType == "win")
{
ending = Windows;
}
else if (targetEndingType == "unix")
{
ending = Unix;
}
else if (targetEndingType == "mac")
{
ending = Mac;
}
string fullPath = Path.GetFullPath(assetImporter.assetPath);
if (!File.Exists(fullPath))
{
Debug.LogError("Error " + fullPath);
return;
}
string fileContents = File.ReadAllText(fullPath);
fileContents = fileContents.Replace(Windows, Unix);
fileContents = fileContents.Replace(Mac, Unix);
fileContents = fileContents.Replace(Unix, ending);
File.WriteAllText(fullPath, fileContents);
EditorApplication.delayCall += () =>
{
AssetDatabase.ImportAsset(fullPath, ImportAssetOptions.ForceUpdate);
};
}
}
}
}