Unity C#执行bat脚本
来源:互联网 发布:项目管理就业前景知乎 编辑:程序博客网 时间:2024/06/01 23:14
using System;using UnityEditor;using UnityEngine;using System.Collections.Generic;using System.IO;using System.Threading;using System.Text;class EdtUtil{public static System.Diagnostics.Process CreateShellExProcess(string cmd, string args, string workingDir = ""){var pStartInfo = new System.Diagnostics.ProcessStartInfo(cmd);pStartInfo.Arguments = args;pStartInfo.CreateNoWindow = false;pStartInfo.UseShellExecute = true;pStartInfo.RedirectStandardError = false;pStartInfo.RedirectStandardInput = false;pStartInfo.RedirectStandardOutput = false;if (!string.IsNullOrEmpty(workingDir))pStartInfo.WorkingDirectory = workingDir;return System.Diagnostics.Process.Start(pStartInfo);}public static void RunBat(string batfile, string args, string workingDir = ""){var p = CreateShellExProcess(batfile, args, workingDir);p.Close();}public static string FormatPath(string path){path = path.Replace("/", "\\");if (Application.platform == RuntimePlatform.OSXEditor)path = path.Replace("\\", "/");}}
现在,我们在工程Assets外层有一个batFiles目录,里面有一个gen_client_cfg.bat脚本
我们想通过Unity菜单执行这个脚本,例
using UnityEngine;using UnityEditor;class Test{private static void RunMyBat(string batFile,string workingDir){var path = EdtUtil.FormatPath(workingDir);if (!System.IO.File.Exists(path)){GameLogger.LogError("bat文件不存在:" + path);}else{EdtUtil.RunBat(batFile, "", path);}}[MenuItem("Tools/生成配置表")]private static void Run(){RunBat("gen_client_cfg.bat", Application.dataPath + "/../batFiles/");}}
阅读全文
0 0
- Unity C#执行bat脚本
- nodejs -- 执行bat脚本
- C#执行bat脚本不出现黑框框的方法
- c# 执行bat文件
- C# 执行 bat文件
- C#执行bat文件
- C# 执行 .Bat文件
- C# 执行bat批处理文件
- Unity中多个C#脚本中的Awake执行顺序
- 批处理bat执行sql脚本
- Unity脚本执行顺序
- Unity脚本执行顺序
- unity脚本执行顺序
- Unity脚本执行顺序
- Unity 脚本执行顺序
- Unity脚本事件执行
- bat脚本中执行另外一个bat脚本
- unity C#脚本规则
- sQL学习(2)
- Android动态设置控件等宽高
- Haskell语言学习笔记(47)Arrow(2)
- UNITY开发中常用的一些API
- 使用MySQL设计大学学籍管理数据库(后台数据库+前台程序)
- Unity C#执行bat脚本
- Haskell语言学习笔记(48)Data.Tuple
- HTML+CSS的练习之网上书城主页面的实现
- SpringCloud教程七:高可用的分布式配置中心(SpringCloud Config)
- Ubuntu16.04+anaconda2+caffe+ssd+opencv3.1.0在编译caffe过程中的问题及解决方法 主要遇到三个问题,前两个是caffe在cmake过程中的问题,后一
- AVL树 封装左旋 右旋操作
- Haskell语言学习笔记(49)ByteString Text
- [构造] BZOJ5100 [POI2018]. Plan metra
- SQl学习(3)