Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wlgys8/UnityShell
execute shell command in Unity Editor
https://github.com/wlgys8/UnityShell
command-line shell unity
Last synced: 6 days ago
JSON representation
execute shell command in Unity Editor
- Host: GitHub
- URL: https://github.com/wlgys8/UnityShell
- Owner: wlgys8
- Created: 2020-03-11T13:39:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-25T02:49:10.000Z (over 2 years ago)
- Last Synced: 2024-08-02T05:13:19.324Z (4 months ago)
- Topics: command-line, shell, unity
- Language: C#
- Size: 22.5 KB
- Stars: 53
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UnityShell
Execute shell commands in Unity Editor, support osx & windows
在Editor下执行windows和osx的命令行
# Install
add follow line to `Packages/manifest.json`
在项目 `Packages/manifest.json` 配置如下的依赖
"com.ms.shell":"https://github.com/wlgys8/UnityShell.git",
# Examples
- execute command `ls`
``` csharp
var operation = EditorShell.Execute("ls");
operation.onExit += (exitCode)=>{
};
operation.onLog += (EditorShell.LogType LogType,string log)=>{
Debug.Log(log);
};int exitCode = await operation; //support async/await
```* use `Options`
``` csharp
var options = new EditorShell.Options(){
workDirectory = "./",
encoding = System.Text.Encoding.GetEncoding("GBK"),
environmentVars = new Dictionary(){
{"PATH","usr/bin"},
}
};var operation = EditorShell.Execute("ls",options);
operation.onExit += (exitCode)=>{
};
operation.onLog += (EditorShell.LogType LogType,string log)=>{
Debug.Log(log);
};```
# Advanced
## Encoding 编码
By default, EditorShell use `UTF8` for encoding. If you get unrecognizable characters, please check your shell app's (`bash` in osx and `cmd.exe` in windows) encoding, and config options.encoding same as that.
在中文版的Windows上运行时,可能会出现乱码。 因为cmd采用了GBK编码,而UnityShell默认使用UTF8编码。 只要在Options里将encoding设置为GBK编码即可
## Environment Vars 环境变量
By default, environment vars is empty. You can config it in options.environmentVars.
默认情况下, 使用EditorShell执行命令行时是不带环境变量的。 你可以通过Options.environmentVars 字段来配置自己需要的环境变量。