Git Product home page Git Product logo

unityshell's Introduction

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
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
var options = new EditorShell.Options(){
    workDirectory = "./",
    encoding = System.Text.Encoding.GetEncoding("GBK"), 
    environmentVars = new Dictionary<string, string>(){
        {"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 字段来配置自己需要的环境变量。

unityshell's People

Contributors

wlgys8 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.