编写Unity的Editor工具提交Svn脚本

开发过程中少不了要提交一些代码,文件,虽然操作过程简单,但是容易遗漏提交文件,写个editor工具可以减少文件漏提交的情况。

    提交到SVN的代码很简单,不过有一个前提,就是要先配置SVN的环境变量。代码如下:

public class SvnTool : EditorWindow
{
    [MenuItem("GameTools/Svn工具")]
    public static void ShowWindow()
    {
        var w = EditorWindow.CreateInstance<SvnTool>();
        w.Show();
    }

    void OnGUI()
    {
        OnCsCommit();
        OnCsUpdate();
    }

    void OnCsCommit()
    {
        if(GUILayout.Button("提交CS代码")
        {
            string path = Application.dataPath + "/Scripts";
            Process.Start(fileName: "TortoiseProc.exe", arguments: "/command:commit /path:" + path + " /logmsg:modify" + " /closeonend:0");
        }
    }
    
    void OnCsUpdate()
    {
        if(GUILayout.Button("更新CS代码")
        {
            string path = Application.dataPath + "/Scripts";
            Process.Start(fileName: "TortoiseProc.exe", arguments: "/command:update /path:" + path + " /closeonend:0");
        }
    }

}

这里面有几个地方要注意:

1 命令里面参数之间是空格格开,比如“/command:update空格/path”。

2 如果要提交多个路径,用"*"连接,比如:

path = Application.dataPath + "/Scripts" + "*" + Application.dataPath + "/Editor";

TortoiseProc.exe的一些命令参数如下:

  • /closeonend:0 不自动关闭对话框

  • /closeonend:1 如果没发生错误则自动关闭对话框

  • /closeonend:2 如果没发生错误和冲突则自动关闭对话框

  • /closeonend:3如果没有错误、冲突和合并,会自动关闭

  • /closeonend:4如果没有错误、冲突和合并,会自动关闭

命令描述
:about显示关于对话框。如果没有给命令也会显示。
:log打开日志对话框,路径指定了日志显示的文件或目录,另外还有三个选项可以设置: /revstart:xxx/revend:xxx/strict
:checkout打开检出对话框,/path指定了目标路径,而/url制定了检出的URL。
:import打开导入对话框,路径制定了数据导入路径。
:updateUpdates the working copy in /path to HEAD. If the option /rev is given then a dialog is shown to ask the user to which revision the update should go.
:commit打开提交对话框,路经指定了目标路径或需要提交的文件列表,你也可以使用参数/logmsg给提交窗口传递预定义的日志信息,或者你不希望将日志传递给命令行,你也可以使用/logmsgfile:path,path指向了保存日志信息的文件。为了预先填入bug的ID(如果你设置了集成bug追踪属性),你可以使用/bugid:"the bug id here"完成这个任务。
:add/path的文件添加到版本控制 。
:revert恢复工作副本的本地修改,/path说明恢复哪些条目。
:cleanup清理中断和终止的操作,将工作副本的/path解锁。
:resolve/path指定文件的冲突标示为解决,如果给定/noquestion,解决不会向用户确认操作。
:repocreate/path创建一个版本库。
:switch打开选项对话框。路径参数指定目标目录。
:export/path的工作副本导出到另一个目录,如果/path指向另一个未版本控制目录,对话框会询问要导出到/path的URL。
:mergeOpens the merge dialog. The path specifies the target directory.
:copy带来branch/tag对话框,/path是branch/tag在工作副本中的出处。
:settings打开设置对话框。
:remove从版本控制里移除/path中的文件。
:rename重命名/path的文件,会在对话框中询问新文件,为了防止一个步骤中询问相似文件,传递/noquestion
:diff启动TortoiseSVN设置的外置比较程序,/path指定了第一个文件,如果设置了/path2,比较程序会启动两个文件,如果省略/path2,比较程序会比较/path和它的BASE。
:conflicteditor打开TortoiseSVN设置的冲突工具,在/path中需要设置冲突文件的正确文件。
:relocate打开重定位对话框,/path指定了重定位的工作副本路径。
:help打开帮助文件
:repostatus打开为修改检出对话框,路经指定了工作副本目录。
:repobrowser打开版本库浏览对话框,URL为工作副本/path指向的或/path直接指出的,另外一个选项是/rev:xxx,可以用来指定要显示的修订版本号,如果省略/rev:xxx,缺省是HEAD。
:ignore/path中的对象加入到忽略列表,也就是将这些文件添加到svn:ignore属性。
:blame打开/path指定文件的追溯对话框,如果设置了startrevendrev,对话框询问追溯范围的对话框不会显示,如果设置了/line:nnn,TortoiseBlame会打开特定文件的某一行。
:cat/path指定的工作副本或URL的文件保存到/savepath:path,修订版本号在/revision:xxx,这样可以得到特定修订版本的文件。
:createpatch创建/path下的补丁文件。
:revisiongraph显示/path目录下的版本变化图。
:lockLocks a file. The 'lock' dialog is shown so the user can enter a comment for the lock. /path
:rebuildiconcache重建windows的图标缓存,只有windows的图标缓存出了问题才需要这样做,一个副作用就是(不可避免)桌面的图标会重新组织。/noquestion
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编写Unity3D的性能测试脚本,您需要使用Unity Editor自带的Profiler工具。下面是一个简单的Python脚本示例,它将自动启动Unity Editor,加载一个场景,运行一些测试,并将结果保存到CSV文件中。 ```python import os import subprocess # Path to the Unity Editor executable UNITY_EDITOR_PATH = "/Applications/Unity/Unity.app/Contents/MacOS/Unity" # Path to the Unity project containing the test scene UNITY_PROJECT_PATH = "/path/to/unity/project" # Name of the test scene to load TEST_SCENE_NAME = "TestScene" # Number of frames to run the test for NUM_FRAMES = 1000 # Start the Unity Editor in batch mode and run the tests def run_tests(): cmd = [ UNITY_EDITOR_PATH, "-batchmode", "-projectPath", UNITY_PROJECT_PATH, "-executeMethod", "TestRunner.RunTests", "-quit" ] subprocess.call(cmd) # Class to run the tests and save the results class TestRunner: # Run the tests and save the results to a CSV file @staticmethod def RunTests(): # Load the test scene UnityEditor.SceneManagement.EditorSceneManager.OpenScene(TEST_SCENE_NAME) # Start the profiler UnityEditor.Profiling.Profiler.enabled = True UnityEditor.Profiling.Profiler.ClearAllFrames() # Run the test for the specified number of frames for i in range(NUM_FRAMES): UnityEditor.EditorApplication.Step() # Stop the profiler and save the results to a CSV file UnityEditor.Profiling.Profiler.enabled = False results = UnityEditor.Profiling.Profiler.GetRawGpuStatistics() with open("test_results.csv", "w") as f: f.write("Frame,Time,GPU Time\n") for i, result in enumerate(results): f.write("{},{},{}\n".format(i, result.frameTime, result.gpuTime)) UnityEditor.EditorApplication.Exit(0) # Start the Unity Editor and run the tests os.chdir(UNITY_PROJECT_PATH) run_tests() ``` 要使用此脚本,请将其保存为.py文件,然后在终端中运行`python script.py`。请注意,您需要将`UNITY_EDITOR_PATH`,`UNITY_PROJECT_PATH`和`TEST_SCENE_NAME`变量设置为适当的值,以便它们指向正确的Unity Editor可执行文件,Unity项目路径和测试场景名称。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值