{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unity-batch-mode/",
  "atlas": "https://www.pystone.net/?node=unity-batch-mode#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unity-batch-mode.md",
  "context": "https://www.pystone.net/notes/unity-batch-mode.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unity-batch-mode",
  "slug": "unity-batch-mode",
  "title": "BatchMode",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "BatchMode",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "df3e6863d6bff19297d027962e9b4c3d170f830a042bba57f01d12e6f770de56",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "BatchMode",
      "anchor": "batchmode",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#batchmode"
    },
    {
      "depth": 2,
      "text": "使用原理",
      "anchor": "使用原理",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E4%BD%BF%E7%94%A8%E5%8E%9F%E7%90%86"
    },
    {
      "depth": 3,
      "text": "DOS",
      "anchor": "dos",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#dos"
    },
    {
      "depth": 4,
      "text": "DOS命令",
      "anchor": "dos命令",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#dos%E5%91%BD%E4%BB%A4"
    },
    {
      "depth": 3,
      "text": "Batch(.bat文件)",
      "anchor": "batchbat文件",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#batchbat%E6%96%87%E4%BB%B6"
    },
    {
      "depth": 4,
      "text": "命令",
      "anchor": "命令",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E5%91%BD%E4%BB%A4"
    },
    {
      "depth": 5,
      "text": "echo 命令",
      "anchor": "echo-命令",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#echo-%E5%91%BD%E4%BB%A4"
    },
    {
      "depth": 5,
      "text": "rem 命令",
      "anchor": "rem-命令",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#rem-%E5%91%BD%E4%BB%A4"
    },
    {
      "depth": 5,
      "text": "pause",
      "anchor": "pause",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#pause"
    },
    {
      "depth": 5,
      "text": "call",
      "anchor": "call",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#call"
    },
    {
      "depth": 5,
      "text": "start",
      "anchor": "start",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#start"
    },
    {
      "depth": 5,
      "text": "goto",
      "anchor": "goto",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#goto"
    },
    {
      "depth": 5,
      "text": "set",
      "anchor": "set",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#set"
    },
    {
      "depth": 4,
      "text": "符号",
      "anchor": "符号",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E7%AC%A6%E5%8F%B7"
    },
    {
      "depth": 3,
      "text": "其他概念",
      "anchor": "其他概念",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E5%85%B6%E4%BB%96%E6%A6%82%E5%BF%B5"
    },
    {
      "depth": 3,
      "text": "Unity Editor拓展",
      "anchor": "unity-editor拓展",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#unity-editor%E6%8B%93%E5%B1%95"
    },
    {
      "depth": 3,
      "text": "Editor方法触发方式",
      "anchor": "editor方法触发方式",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#editor%E6%96%B9%E6%B3%95%E8%A7%A6%E5%8F%91%E6%96%B9%E5%BC%8F"
    },
    {
      "depth": 4,
      "text": "MenuItem",
      "anchor": "menuitem",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#menuitem"
    },
    {
      "depth": 4,
      "text": "EditorWindow->Button",
      "anchor": "editorwindow-button",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#editorwindow-button"
    },
    {
      "depth": 4,
      "text": "利用批处理来调用",
      "anchor": "利用批处理来调用",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E5%88%A9%E7%94%A8%E6%89%B9%E5%A4%84%E7%90%86%E6%9D%A5%E8%B0%83%E7%94%A8"
    },
    {
      "depth": 5,
      "text": "命令介绍",
      "anchor": "命令介绍",
      "citation": "https://www.pystone.net/notes/unity-batch-mode/#%E5%91%BD%E4%BB%A4%E4%BB%8B%E7%BB%8D"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unity中的“BatchMode”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unity"
    }
  ],
  "contentMarkdown": "# BatchMode\n\n> 创建时间：2020/6/16 18:51\n\n  * BatchMode\n    * 使用原理\n      * DOS\n        * DOS命令\n      * Batch(.bat文件)\n        * 命令\n          * echo 命令\n          * rem 命令\n          * pause\n          * call\n          * start\n          * goto\n          * set\n        * 符号\n      * 其他概念\n      * Unity Editor拓展\n      * Editor方法触发方式\n        * MenuItem\n        * EditorWindow->Button\n        * 利用批处理来调用\n          * 命令介绍\n\n## 使用原理\n\n### DOS\n\nDOS是Disk Operation System(磁盘操作系统）的简称，是个人计算机上的一类操作系统。它直接操纵管理硬盘的文件，一般都是黑底白色文字的界面。\nDOS就是人与机器的一座桥梁，是罩在机器硬件外面的一层“外壳”，只需通过一些接近于自然语言的DOS命令，就可以轻松地完成绝大多数对机器的日常操作。\n此外，DOS还能有效地管理各种软硬件资源，对它们进行合理的调度，所有的软件和硬件都在DOS的监控和管理之下，有条不紊地进行着自己的工作，但是在操作不慎情况下也会死机。\n**MS-DOS** 是MicroSoft-dos，它不是纯DOS，是基于Windows的DOS程序，在功能上类似于DOS，但是不一样。\n最新的Windows操作系统中，MS-dos的核心依然存在，只是加上Windows当作系统的图形界面。\n微软图形界面操作系统 Windows NT 问世以来，DOS是一个 **后台程序** 的形式出现的。名为 **Windows命令提示符** 。可以通过点击运行- **CMD** 进入。\n\n#### DOS命令\n\nDOS命令行不许要去专门当做一门语言学习，你只需要根据自己的需求百度一下命令行的使用方式即可。\n\n### Batch(.bat文件)\n\n**批处理(Batch)** ，也称为 **批处理脚本** 。通常被认为是一种简化的脚本语言，也称作宏。它应用于DOS和Windows系统中。\n它是由DOS或者Windows系统内嵌的命令解释器（通常是COMMAND. COM或者CMD.EXE）解释运行。类似于Unix中的Shell脚本。批处理文件具有.bat或者.cmd的扩展名，其最简单的例子，是逐行书写在命令行中会用到的各种命令。\n**使用** ：在“命令提示”下键入批处理文件的名称，或者双击该批处理文件，系统就会调用Cmd.exe运行该批处理程序。\n**运行** ：运行批处理程序时，首先扫描整个批处理程序，然后从第一行代码开始向下逐句执行所有的命令，直至程序结尾或遇见exit命令或出错意外退出。\n\n> 批处理程序虽然是在命令行环境中运行，但不仅仅能使用命令行软件，任何当前系统下可运行的程序都可以放在批处理文件中运行。\n\n#### 命令\n\n##### echo 命令\n\n语法: echo [{on|off}] [message]\nSample：@echo off / echo hello world\n\n打开回显或关闭请求回显功能，或显示消息。如果没有任何参数，echo命令将显示当前回显设置。\n在实际应用中我们会把这条命令和重定向符号（也称为管道符号，一般用> >> ^）结合来实现输入一些命令到特定的文件中，例如：\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n在批处理文件的开头，通常有：\necho off\n原因是”@”可以将本行的命令关闭回显，搭配”echo off”就可以不显示”echo off”的回显了。\n\n##### rem 命令\n\n语法：Rem [注释内容]\nSample：Rem 你好。\n\n注释命令，类似于在C语言中的/ _——–_ /，它并不会被执行，只是起一个注释的作用，只有在编辑批处理时才会被看到，主要用于方便修改。\n:: 也具有rem的功能\n但::和rem还是有区别的，当关闭回显时，rem和::后的内容都不会显示。\n但是当打开回显时，rem后的内容会显示出来，然而::后的内容仍然不会显示。\n\n##### pause\n\n暂停命令。运行 Pause 命令时，将显示下面的消息：\nPress any key to continue…（或：请按任意键继续…)\n\n##### call\n\n##### start\n\n##### goto\n\n##### set\n\n#### 符号\n\n### 其他概念\n\nBash(Bourne-Again SHell): Unix shell的一种，能运行于大多数类Unix系统的操作系统之上，包括Linux与Mac OS X v10.4都将它作为默认shell。\n是一个命令处理器，通常运行于文本窗口中，并能执行用户直接输入的命令。Bash还能从文件中读取命令，这样的文件称为脚本。\n\n### Unity Editor拓展\n\n放在工程目录下Assets/Editor文件下的方法都是对Unity引擎编辑器的拓展，一般常见的插件都会编写一部分编辑器拓展代码来自定义插件的Inspector面板等其他操作。\n\n### Editor方法触发方式\n\n#### MenuItem\n\n#### EditorWindow->Button\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n#### 利用批处理来调用\n\n更多Unity Command line arguments：<https://docs.unity3d.com/Manual/CommandLineArguments.html>\n\n> 最新Unity支持直接用.bat脚本直接导出linux、MacOS、Window的应用，暂时不支持Android和IOS等其它终端的输出。\n\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n```csharp\nstring s1 = &quot;Hello &quot;;\nstring s2 = s1;\ns1 += &quot;World&quot;;\n\nSystem.Console.WriteLine(s2);\n//Output: Hello\n\n```\n\n##### 命令介绍\n\necho 为DOS编程中一种显示消息的方法\n\nstart DOS编程中用于启动应用程序的命令\n-batchmode 是Unity提供的Command line arguments中较为常用的一种，它是后台运行Unity，不显示Unity界面，这对于把机械的工作交给策划？美术？是极其重要的。\n在-batchmode下运行Unity。这应该始终与其他命令行参数一起使用，因为 **它确保没有出现弹出窗口，并且不需要任何人为干预** 。执行脚本代码期间发生异常时，资产服务器更新失败或其他失败的操作，Unity立即退出并返回代码1。\n请注意，在批处理模式下，Unity将其日志输出的最小版本发送到控制台。但是，日志文件仍然包含完整的日志信息。在编辑器打开相同的项目时以批处理模式打开项目不受支持; Unity的一个实例只能一次运行。\n\n-projectPath 指定项目的路径\n\n-executeMethod(ClassName.MethodName) 调用Unity编辑器某个类型中的某个方法\n\n一旦Unity启动，项目打开，并且执行了可选的Asset Server更新之后，执行静态方法。这可以用于执行持续集成，执行单元测试，构建或准备数据等任务。要从命令行进程返回错误，请抛出异常，导致Unity退出代码1，或者使用非零返回代码调用EditorApplication.Exit。要传递参数，将它们添加到命令行并使用函数检索它们System.Environment.GetCommandLineArgs。要使用-executeMethod，您需要将封闭的脚本放在编辑器文件夹中。要执行的方法必须定义为static。\n\nRef: <https://blog.csdn.net/qq_29579137/article/details/76598929>\n"
}
