您的位置:首页 > 汽车 > 时评 > 深圳高速建设公司_中国证券监督管理委员会电话号码_北京网站优化技术_北京百度推广投诉电话

深圳高速建设公司_中国证券监督管理委员会电话号码_北京网站优化技术_北京百度推广投诉电话

2024/10/18 12:11:22 来源:https://blog.csdn.net/Eugen009/article/details/142230734  浏览:    关键词:深圳高速建设公司_中国证券监督管理委员会电话号码_北京网站优化技术_北京百度推广投诉电话
深圳高速建设公司_中国证券监督管理委员会电话号码_北京网站优化技术_北京百度推广投诉电话
  1. 虽然改名, 在unity里有AssetDatabase.RenameAsset, 或AssetDatabase.MoveAsset, 但这里难点不是改名,而是怎么让GIT知道修改文件. Git是大小敏感, 而Win是大小不敏感的, 通常开发中,GIT确实没发知道文件名有变动.
  2. Git提供mv 指令,可以通知文件有变动,
git mv oldFilenPath newFilePath
  1. 实际项目中, 资源中会有多个仓库,方便各模块的管理, 可以通过 - C选项指定仓库目录
git -C oldFileDir mv oldFilePat newFilePath
  1. 在C# 中间可以创建Process来调用外部exe, 结合以上, 可以在unity里实现改名同时让git 知道文件名被修改
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}");}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com