Version: 2019.2
Obsolete public static bool SwitchActiveBuildTarget (BuildTarget target);
public static bool SwitchActiveBuildTarget (BuildTargetGroup targetGroup, BuildTarget target);

パラメーター

targetビルド時の対象プラットフォームを選択します
targetGroupビルドする対象プラットフォームを選択します

戻り値

bool True の場合、ビルドターゲットを正常に切り替えされました。False の場合はそれ以外 ( たとえば、ライセンスチェックを失敗してファイルが見つからなかった、ユーザーが UI を通じて操作をキャンセルした、など ) です。

説明

アクティブにする新しいビルドターゲットを選択します。

Has the same effect as changing the build target via the Build Player dialog in the Editor.

When you change the currently active build target, this function reimports Assets that are affected by the current platform setting, and then returns. All script files are compiled on the next editor update. To have scripts compile before the Assets are reimported, see SwitchActiveBuildTargetAsync.

指定されたターゲットがスタンドアロンターゲットの場合、SwitchActiveBuildTarget を呼び出すことは EditorUserBuildSettings.selectedStandaloneTarget にも影響します。

"注:" このメソッドは batch mode で Editor を実行する場合、利用できません。これはスクリプトコードを実行する間、ビルドターゲットを変更することができない指定されたターゲットのためにスクリプトコードを再コンパイルすることが必要だからです ( Editor では問題ではありません。操作は単に遅れるだけです。しかし、バッチモードは指定されたスクリプト コードの実行後直ちに終了します)。バッチモードで使用するビルドターゲットを設定するには buildTarget コマンドライン スイッチを使用します。

using UnityEditor;

public class SwitchPlatformExample { [MenuItem("Example/Switch Platform")] public static void PerformSwitch() { // Switch to Windows standalone build. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows); } }