游戏测试 【测试工具】Unity Editor 中写个 svn update 工具

特尔斯特 · 2021年02月23日 · 最后由 吴秋楠 回复于 2021年03月02日 · 2516 次阅读

场景 1:每次前端更新后都要找到指定项目文件夹更新 svn 才能测试,所以在 untiyEditor 中写了个 SVN update 工具。
场景 2:开发人员经常说之前提的 BUG 现在又没有了,希望能在 bug 单中写入 svn 版本号,所以每次提 BUG 还得手动记录 svn version ,干脆把这个也一起做了。
效果图:

public class GMPanel:EditorWindow
{
      GMPanel()
      {
        GetSvnVersion();
      }


        [MenuItem("QA/GM面板")]
        public static void OpenWindow()
       {
                  EditorWindow.GetWindow(typeof(GMPanel));
        }

        void OnGUI()
        {
                    this.titleContent = new GUIContent("GM面板");
                    //显示svn版本号
                    GUILayout.Label("当前SVN版本号:" + svnVersion);

                     if (GUILayout.Button("SVN Update", GUILayout.Width(100), GUILayout.Height(30)))
                    {
                            //执行svn update
                              RunCmd("TortoiseProc.exe /command:update /path:\"../\" /closeonend:0");
                             GetSvnVersion();

                      }
        }

   //操作cmd命令行
    private static string RunCmd(string command)
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe";           //确定程序名
        p.StartInfo.Arguments = "/c " + command;    //确定程式命令行
        p.StartInfo.UseShellExecute = false;        //Shell的使用
        p.StartInfo.RedirectStandardInput = true;   //重定向输入
        p.StartInfo.RedirectStandardOutput = true; //重定向输出
        p.StartInfo.RedirectStandardError = true;   //重定向输出错误
        p.StartInfo.CreateNoWindow = true;          //设置置不显示示窗口
        p.Start();
        return p.StandardOutput.ReadToEnd();        //输出出流取得命令行结果果       
    }

    //得到svnVersion 
    void GetSvnVersion()
    {
        RunCmd("svn info");
        string svninfo = RunCmd("svn info");
        string[] strArray = svninfo.Split('\n');
        svnVersion = strArray[6].Split(':')[1];
    }
}

注:环境变量中必须配置了 svn

共收到 1 条回复 时间 点赞

继承的 EditorWindow 才是重头戏

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册