搜索
您的当前位置:首页正文

Untiy中给资源名改大小写

来源:好走旅游网
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}");
       }
   }

因篇幅问题不能全部显示,请点此查看更多更全内容

Top