facebook twitter hatena line email

「Unity/Editor/コマンド実行」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(コマンド実行)
(サンプル)
行9: 行9:
 
using UnityEditor;
 
using UnityEditor;
 
using UnityEngine;
 
using UnityEngine;
using UnityEditor.Build.Reporting;
 
 
class MyEditorScript
 
class MyEditorScript
 
{
 
{

2021年8月6日 (金) 16:05時点における版

コマンド実行の対応方法

UnityEditorを使って、commandで実行

公式マニュアル:https://docs.unity3d.com/ja/2019.4/Manual/CommandLineArguments.html

サンプル

Assets/Editor/MyEditorScript.cs

using UnityEditor;
using UnityEngine;
class MyEditorScript
{
    static void Exec()
    {
        Debug.Log("Build Start");
    }
}

コマンド実行

mac

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.Exec

mac(unity hub)

/Applications/Unity/Hub/Editor/2019.4.26f1/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.Exec

参考:https://docs.unity3d.com/ja/2019.4/Manual/CommandLineArguments.html

project openエラーが出るとき

プロジェクトをGUIで開いているとエラーが出るので、閉じてからコマンド実行する

Aborting batchmode due to failure:
Fatal Error! It looks like another Unity instance is running with this project open.
Multiple Unity instances cannot open the same project.

compiler errorsが出るとき

ビルドが失敗してるので、プラットフォームが正しいかなど確認する。(GUI上での実行だと、スクリプトエラーが発生してるはず)

Aborting batchmode due to failure:
Scripts have compiler errors.