【Windows】Unity上からコマンドプロンプトを起動したい
はじめに
Unity上からWindowsのコマンドプロンプトを起動するにはどうすればいいのか気になったので調べてみました。
OSはWindows 10です.
ソースコード
EditorRunTerminal.cs
using UnityEditor;
using System.Diagnostics;
public class EditorRunTerminal
{
[MenuItem("Window/Run Terminal %t")]
static void RunTerminal()
{
Process p = new Process();
p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
p.StartInfo.Arguments = "/k cd Assets";
p.Start();
}
}
結果
EditorRunTerminal.cs
using UnityEditor;
using System.Diagnostics;
public class EditorRunTerminal
{
[MenuItem("Window/Run Terminal %t")]
static void RunTerminal()
{
Process p = new Process();
p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
p.StartInfo.Arguments = "/k cd Assets";
p.Start();
}
}
参考
外部アプリケーションを起動する、ファイルを関連付けられたソフトで開く
http://dobon.net/vb/dotnet/process/shell.html
DOSコマンドを実行し出力データを取得する
http://dobon.net/vb/dotnet/process/standardoutput.html
コマンドプロンプト起動時のオプション一覧(windows)
http://blog.layer8.sh/ja/2011/12/16/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AE%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3/
Author And Source
この問題について(【Windows】Unity上からコマンドプロンプトを起動したい), 我々は、より多くの情報をここで見つけました https://qiita.com/r-ngtm/items/c66e877a8b91c480d9ba著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .