CmdTools必須在Editor文件夾內(nèi)
打開(kāi)CMD世澜,輸入以下命令
"C:\Program Files\Unity2018.4.16f1\Editor\Unity.exe" -projectPath "E:\Demo\CMDTest" -executeMethod CMD.CmdTools.CallByCmd GetCommandLineArgs 你好 132456 abcdefa
代碼
using System;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace CMD
{
public class CmdTools : Editor
{
/// 外部命令行調(diào)起來(lái)
/// </summary>
public static void CallByCmd()
{
//得到命令行傳入的參數(shù)
string[] arguments = Environment.GetCommandLineArgs();
Debug.LogError("參數(shù)數(shù)量:" + arguments.Length);
Process.Start(Application.dataPath);
}
}
}
image.png
參考:
https://docs.unity3d.com/Manual/CommandLineArguments.html
https://docs.unity3d.com/Manual/PlayerCommandLineArguments.html