git mv oldFilenPath newFilePath
git -C oldFileDir mv oldFilePat newFilePath
private void TestRenameAsset(string path)
{
try
{
var oldPath = path.Replace("\\", "/");
var dir = Path.GetDirectoryName(oldPath);
var newPath = dir + "/" + Path.GetFileName(oldPath).ToLower();
AssetDatabase.MoveAsset(path, newPath);
using (var process = new Process())
{
var abOldPath = Path.GetFullPath(oldPath);
var abNewPath = Path.GetFullPath(newPath);
var abDir = Path.GetFullPath(dir);
process.StartInfo.FileName = "git";
process.StartInfo.Arguments = $"-C \"{abDir}\" mv \"{abOldPath}\" \"{abNewPath}\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
}
}
catch (Exception e)
{
UnityEngine.Debug.LogError($"Fail to rename asset to lower: {e}");
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容