Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

EditorUserBuildSettings.SwitchActiveBuildTarget

Предложить изменения

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Закрыть

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста <a>попробуйте снова</a> через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Закрыть

Отменить

Руководство
public static function SwitchActiveBuildTarget(target: BuildTarget): bool;
public static bool SwitchActiveBuildTarget(BuildTarget target);

Параметры

Возврат значений

bool True if the build target was successfully switched, false otherwise (for example, if license checks fail, files are missing, or if the user has cancelled the operation via the UI).

Описание

Select a new build target to be active.

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

Changing the currently active build target will recompile all script files for the new platform and will reimport assets that are affected by the current platform setting (textures with platform-specific settings, for example).

If the given target is a standalone target, calling SwitchActiveBuildTarget will also affect EditorUserBuildSettings.selectedStandaloneTarget.

Note: This method is not available when running the Editor in batch mode. This is because changing the build target requires recompiling script code for the given target which cannot be done while script code is executing (not a problem in in the editor as the operation is simply deferred but batch mode will immediately exit after having executed the designated script code). To set the build target to use in batch mode, use the buildTarget command-line switch.


        
using UnityEngine;
using UnityEditor;

public class ExampleClass : MonoBehaviour { void Start() { // Switch to Windows standalone build. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows); } }