/// <summary> /// Helper function that generates a build. /// </summary> private static void GenericBuild(string targetDirectory, BuildTarget buildTarget) { // Import assets to this platform EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget); // Determine the best build option BuildOptions buildOption = OptionsAll; if (buildTarget == BuildTarget.WebPlayer) { buildOption |= OptionsWeb; } // Build everything based on the options string res = BuildPipeline.BuildPlayer(AllScenes, targetDirectory, buildTarget, buildOption); if (res.Length > 0) { throw new Exception("Failed to build to " + targetDirectory + ":\n" + res); } }
public static void BuildForTraining() { Scene scene = SceneManager.GetSceneByName(SceneName); GameObject[] gameObjects = scene.GetRootGameObjects(); GameObject academyObject = gameObjects.FirstOrDefault(g => g.name == "Academy"); if (academyObject != null) { Brain brain = academyObject.GetComponentInChildren <Brain>(); brain.brainType = BrainType.External; } else { Debug.LogError("Brain not found on current scene!"); } string[] scenes = new[] { ScenePath }; EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); BuildPipeline.BuildPlayer(scenes, BuildPath + ExecutableName, BuildTarget.StandaloneWindows, BuildOptions.None); }
public static void Build(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, BuildParam buildParam, bool batchMode) { BuildManager.buildTarget = buildTarget; BuildManager.buildParam = buildParam; BuildManager.batchMode = batchMode; if (EditorUserBuildSettings.activeBuildTarget != buildTarget) { IsBuildWait = true; #if UNITY_5_6_OR_NEWER EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildTarget); #else EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget); #endif } else { BuildPlayer(); } }
public static void BuildProjectAllSceneAndroid() { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android); List <string> allScene = new List <string>(); foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { if (scene.enabled) { allScene.Add(scene.path); } } PlayerSettings.applicationIdentifier = "taiki.sample.canvasgame"; PlayerSettings.statusBarHidden = true; BuildPipeline.BuildPlayer( allScene.ToArray(), "canvasgame.apk", BuildTarget.Android, BuildOptions.None ); }
static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options) { try { Directory.CreateDirectory(Application.dataPath + "/../" + target_dir); } catch (IOException) {} build_options |= ReadCommandLineArguments(ref target_dir); EditorUserBuildSettings.SwitchActiveBuildTarget(build_target); string res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options); if (res.Length > 0) { throw new Exception("BuildPlayer failure: " + res); } else { Debug.LogFormat("Finished building {0} to '{1}'", build_target.ToString(), target_dir); } }
static void GenericBuild(string[] scenes, string target_dir, BuildTargetGroup targetGroup, BuildTarget build_target, BuildOptions build_options) { EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, build_target); string res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options); if (res.Length > 0) { throw new Exception("BuildPlayer failure: " + res); } ProcessStartInfo pi = new ProcessStartInfo( #if UNITY_EDITOR_WIN "explorer.exe", #elif UNITY_EDITOR_OSX "open", #endif TARGET_DIR ); Process.Start(pi); }
private void ConfigureSettings() { PlayerSettings.virtualRealitySupported = true; UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup( PlatformSettings.BuildTargetGroup, PlatformSettings.enabledXrTargets); if (PlatformSettings.enabledXrTargets.FirstOrDefault() != "WindowsMR") { EditorUserBuildSettings.SwitchActiveBuildTarget( PlatformSettings.BuildTargetGroup, PlatformSettings.BuildTarget); } PlayerSettings.stereoRenderingPath = PlatformSettings.stereoRenderingPath; PlayerSettings.Android.minSdkVersion = PlatformSettings.minimumAndroidSdkVersion; EditorUserBuildSettings.androidBuildType = AndroidBuildType.Development; EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle; }
public static void BuildAndroid() { foreach (EditorBuildSettingsScene item in EditorBuildSettings.scenes) { if (!item.enabled) { continue; } levels.Add(item.path); } EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); //PlayerSettings.companyName = "cm"; //PlayerSettings.productName = "WWW"; // PlayerSettings.applicationIdentifier = "com.cm.WWW"; string res = BuildPipeline.BuildPlayer(levels.ToArray(), "WWW.apk", BuildTarget.Android, BuildOptions.None); if (res.Length > 0) { throw new Exception("BuildPlayer failure:" + res); } }
private static void build(string[] levels, BuildTarget buildTarget, string deployPath, string ext, bool debug = true) { var buildOptions = debug ? (BuildOptions.AllowDebugging | BuildOptions.Development) : BuildOptions.None; var productName = "kingdom"; try { PlayerSettings.bundleVersion = "0." + System.Environment.GetEnvironmentVariable("P4_CHANGELIST"); } catch (System.Exception) { PlayerSettings.bundleVersion = "0xd3adb33f"; } var buildPath = Application.dataPath + "/../../Build" + deployPath + productName.Replace(" ", "") + ext; EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget); //string errors = BuildPipeline.BuildPlayer(levels, buildPath, buildTarget, buildOptions); }
static void GenericBuild(string[] scenes, string target_dir, BuildTargetGroup targetGroup, BuildTarget build_target, BuildOptions build_options) { EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, build_target); string res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options); if (res.Length > 0) { UnityEngine.Debug.LogFormat("<color=red>BuildPlayer error: {0}</color>", res); } ProcessStartInfo pi = new ProcessStartInfo( #if UNITY_EDITOR_WIN "explorer.exe", #elif UNITY_EDITOR_OSX "open", #endif TARGET_DIR ); Process.Start(pi); }
public static void BuildProjectAllSceneIOSandAndroid() { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS); List <string> allScene = getAllScene(); PlayerSettings.bundleIdentifier = "com.Kurakura.jenkinsTest0323"; PlayerSettings.statusBarHidden = true; BuildPipeline.BuildPlayer( allScene.ToArray(), "iosProject", BuildTarget.iOS, BuildOptions.None ); EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); BuildPipeline.BuildPlayer( allScene.ToArray(), "game.apk", BuildTarget.Android, BuildOptions.None ); }
public static void BuildProjectAllSceneAndroid() { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); List <string> allScene = new List <string>(); foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { if (scene.enabled) { allScene.Add(scene.path); } } PlayerSettings.bundleIdentifier = "com.yourcompany.newgame"; PlayerSettings.statusBarHidden = true; BuildPipeline.BuildPlayer( allScene.ToArray(), "newgame.apk", BuildTarget.Android, BuildOptions.None ); }
/// <summary> /// Upload a package, using the specified options. /// </summary> /// <param name="username">The username credentials to use for package uploading.</param> /// <param name="password">The password credentials to use for package uploading.</param> /// <param name="packageName">The package name. The package must be set to draft status in the Publisher Administration.</param> /// <param name="rootPath">The root path of the package (relative to Application.dataPath). If null, use the project Assets folder.</param> /// <param name="mainAssets">An array of the main assets for the package (relative to Application.dataPath). If null, do not upload or change any main assets.</param> /// <param name="loginTimeout">The maximum amount of time to wait (in seconds) when logging in. Defaults to 90 seconds. Must be within 2 and 36000 seconds. Login is attempted twice.</param> /// <param name="metadataTimeout">The maximum amount of time to wait (in seconds) when getting metadata. Defaults to 600 seconds. Must be within 2 and 36000 seconds.</param> /// <param name="uploadTimeout">The maximum amount of time to wait (in seconds) when uploading. Defaults to 36000 seconds. Must be within 2 and 36000 seconds.</param> public static void UploadAssetStorePackage(string username, string password, string packageName, string rootPath = null, string[] mainAssets = null, int loginTimeout = 90, int metadataTimeout = 600, int uploadTimeout = 36000, bool skipProjectSettings = false) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException("username"); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (string.IsNullOrEmpty(packageName)) { throw new ArgumentNullException("packageName"); } s_Username = username; s_Password = password; s_PackageName = packageName; s_RootPath = rootPath; s_MainAssets = mainAssets; s_LoginTimeout = Mathf.Clamp(loginTimeout, 2, 36000); s_MetadataTimeout = Mathf.Clamp(metadataTimeout, 2, 36000); s_UploadTimeout = Mathf.Clamp(uploadTimeout, 2, 36000); s_SkipProjectSettings = skipProjectSettings; Finish(); #if !UNITY_5_5_OR_NEWER if (Application.webSecurityEnabled) { Debug.Log("[Asset Store Batch Mode] Switching from Web Player platform..."); EditorUserBuildSettings.SwitchActiveBuildTarget(EditorUserBuildSettings.selectedStandaloneTarget); } #endif EditorApplication.update += Update; }
private static void BuildWindows(bool isDevelop) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); Debug.Log($@" ===Player Settings=== id = {PlayerSettings.applicationIdentifier} version = {PlayerSettings.bundleVersion} ===================== "); // バンドルアセットをコピー CopyDirectory("BundleAssets", "Builds/Windows", true); CopyDirectory("UserData", "Builds/Windows/UserData", true); var buildOptions = new BuildPlayerOptions { scenes = EditorBuildSettings.scenes.Select(s => s.path).ToArray(), locationPathName = $"Builds\\Windows\\{Application.productName}.exe", target = BuildTarget.StandaloneWindows64, options = isDevelop ? BuildOptions.Development : BuildOptions.AllowDebugging }; Build(buildOptions); // IL2CPPの場合シンボルファイルを外に移動 if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone) != ScriptingImplementation.IL2CPP) { return; } var dest = "Builds/Windows_IL2CPPBackup"; if (Directory.Exists(dest)) { Directory.Delete(dest, true); } Directory.Move($"Builds/Windows/{projectName}_BackUpThisFolder_ButDontShipItWithYourGame", dest); }
public static void Build(bool fast) { _scenes = FindEnabledEditorScenes(); EditorUserBuildSettings.SwitchActiveBuildTarget(_target); if (Directory.Exists(_targetDir)) { try { Directory.Delete(_targetDir, true); } catch (System.Exception e) { XDebug.Log(e.Message); } } Directory.CreateDirectory(_targetDir); if (!fast) { XPriorBuild.OnPriorBuild(fast, EditorUserBuildSettings.activeBuildTarget); } string lastName = ""; if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { lastName = ".apk"; } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows) { lastName = ".exe"; } string dest = Path.Combine(_targetDir, "dnasset" + lastName); string res = BuildPipeline.BuildPlayer(_scenes, dest, _target, _build); string macro = XBuild.Macro; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, macro); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, macro); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, macro); if (!fast) { XPostBuild.OnPostBuild(fast, EditorUserBuildSettings.activeBuildTarget); } EditorUtility.DisplayDialog("Package Build Finish", "Package Build Finish!(" + res + ")", "OK"); HelperEditor.Open(_targetDir); }
static void ActualPerformBuild(bool useDebug) { print("BuildBot Started"); BuildTargetGroup target = GetBuildTargetGroup(); EditorUserBuildSettings.selectedBuildTargetGroup = target; ModifyDefineSymbols(target, useDebug, "DEBUG"); string[] scenes = FindEnabledEditorScenes(); string targetDir = "IOSBuild"; string fullPath = Application.dataPath.Replace("Assets", targetDir); System.IO.Directory.CreateDirectory(fullPath); CustomDebug.Log("Creating path : " + fullPath); #if !UNITY_5 EditorUserBuildSettings.appendProject = false; #endif print("ABT:" + EditorUserBuildSettings.activeBuildTarget); BuildConfig config = new BuildConfig(); config.scenes = scenes; config.fullPath = fullPath; if (EditorUserBuildSettings.activeBuildTarget != GetBuildTarget()) { lastConfig = config; CustomDebug.Log("Switching BuildTarget"); EditorUserBuildSettings.activeBuildTargetChanged += startBuildingPlayer; EditorUserBuildSettings.SwitchActiveBuildTarget(GetBuildTarget()); } else { Build(config); } }
private void SaveAvatar(AvatarDescriptor avatar) { string destinationPath = EditorUtility.SaveFilePanel("Save avatar file", null, avatar.name + ".avatar", "avatar"); if (string.IsNullOrEmpty(destinationPath)) { return; } string destinationFileName = Path.GetFileName(destinationPath); string tempFolder = Application.temporaryCachePath; string tempAssetBundlePath = Path.Combine(Application.temporaryCachePath, destinationFileName); string prefabPath = Path.Combine("Assets", "_CustomAvatar.prefab"); PrefabUtility.SaveAsPrefabAsset(avatar.gameObject, prefabPath); AssetBundleBuild assetBundleBuild = new AssetBundleBuild { assetBundleName = destinationFileName, assetNames = new[] { prefabPath } }; assetBundleBuild.assetBundleName = destinationFileName; BuildTargetGroup selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; BuildTarget activeBuildTarget = EditorUserBuildSettings.activeBuildTarget; BuildPipeline.BuildAssetBundles(tempFolder, new[] { assetBundleBuild }, 0, EditorUserBuildSettings.activeBuildTarget); EditorUserBuildSettings.SwitchActiveBuildTarget(selectedBuildTargetGroup, activeBuildTarget); File.Copy(tempAssetBundlePath, destinationPath, true); AssetDatabase.DeleteAsset(prefabPath); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("Export Successful!", $"{avatar.name} was exported successfully!", "OK"); }
public static void Build() { BuildTarget buildTarget = BuildTarget.Android; // 切换到 Android 平台 EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget); //// keystore 路径, G:\keystore\one.keystore //PlayerSettings.Android.keystoreName = "G:\\keystore\\one.keystore"; //// one.keystore 密码 //PlayerSettings.Android.keystorePass = "******"; //// one.keystore 别名 //PlayerSettings.Android.keyaliasName = "bieming1"; //// 别名密码 //PlayerSettings.Android.keyaliasPass = "******"; List <string> levels = new List <string>(); foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { if (!scene.enabled) { continue; } // 获取有效的 Scene levels.Add(scene.path); } // 打包出 APK 名 string apkName = string.Format(@"C:\{0}.apk", "Test"); // 执行打包 string res = BuildPipeline.BuildPlayer(levels.ToArray(), apkName, buildTarget, BuildOptions.None); AssetDatabase.Refresh(); }
public static void BuildWebGL() { // Switch to WebGL build. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL); PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm; PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Brotli; PlayerSettings.WebGL.debugSymbols = false; PlayerSettings.WebGL.dataCaching = false; PlayerSettings.stripEngineCode = false; BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); List <string> scenes = new List <string>(); foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { if (scene.enabled) { scenes.Add(scene.path); } } buildPlayerOptions.scenes = scenes.ToArray(); buildPlayerOptions.locationPathName = "LBRY/Build"; buildPlayerOptions.target = BuildTarget.WebGL; buildPlayerOptions.options = BuildOptions.UncompressedAssetBundle; BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary; if (summary.result == BuildResult.Succeeded) { UnityEngine.Debug.Log("Build succeeded: " + summary.totalSize + " bytes"); } else if (summary.result == BuildResult.Failed) { UnityEngine.Debug.Log("Build failed"); } }
public static void PackAB_IOS() { //修改assetbundles生成路径 var buildString = GetBuildString(); if (buildString != null) { buildParameter = new BuildParameter(); buildParameter.SetExtraArg(buildString); } //判断是不是iOS平台 if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) { PackAB(BuildTarget.iOS); } else { curState = AutoPackerState.Pack_AB; EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); } }
private void BuildAssetsBundle() { if (bl_BuildIOS) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS); BuildPipeline.BuildAssetBundles(str_StreamingAssetsPath + "/" + str_BakeAssetBundlePath + "/" + str_IOSPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.iOS); } if (bl_BuildMac) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneOSXUniversal); BuildPipeline.BuildAssetBundles( str_StreamingAssetsPath + "/" + str_BakeAssetBundlePath + "/" + str_MACPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneOSXUniversal); } if (bl_BuildWindow) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows64); BuildPipeline.BuildAssetBundles( str_StreamingAssetsPath + "/" + str_BakeAssetBundlePath + "/" + str_WINDOWPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64); } }
static void BuildGame() { ClearLog(); CheckPasswords(); string apk = PlayerSettings.bundleIdentifier + ".apk"; DateTime creationTime = File.GetCreationTime(apk); EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); BuildPipeline.BuildPlayer(GetSceneNames(), apk, BuildTarget.Android, BuildOptions.None); if (File.GetCreationTime(apk).Equals(creationTime)) { UnityEngine.Debug.LogError("Failed to build " + apk); } else { UnityEngine.Debug.Log("Successfully built " + apk); UnityEngine.Debug.LogWarning("Don't forget to use ALT-CMD-I to install."); } }
public static void SwitchPlatform(BuildTarget BuildVersionTarget) { if (BuildVersionTarget == BuildTarget.StandaloneWindows) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows); PlayerSettings.bundleVersion = LogicConstantData.g_version; } else if (BuildVersionTarget == BuildTarget.Android) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android); PlayerSettings.Android.keystorePass = "******"; PlayerSettings.Android.keyaliasPass = "******"; PlayerSettings.Android.keystoreName = EditorHelper.GetProjPath("Tools/Keystore/user.keystore"); PlayerSettings.bundleVersion = LogicConstantData.g_version; } else if (BuildVersionTarget == BuildTarget.iOS) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); PlayerSettings.bundleVersion = LogicConstantData.g_version; } AssetDatabase.Refresh(); }
static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL); BuildReport buildReport = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options); if (buildReport.summary.result == BuildResult.Succeeded) { Debug.Log("打包成功!-->" + platformType + "\n Size=" + buildReport.summary.totalSize + " bytes"); if (platformType == PlatformType.Online) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.WebGL, _processorDirectivesTemp); } FileDialog.OpenFileDialog(Application.dataPath.Replace("Assets", "").Replace("/", "\\") + "0830"); } else if (buildReport.summary.result == BuildResult.Failed) { Debug.Log("打包失败!"); } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
public static void PerformBuild() { // the scenes we want to include in the build string[] scenes = { "Assets/Scenes/MainMenu.unity", "Assets/Scenes/Procedural.unity", "Assets/Scenes/Multiplayer.unity" }; string path = "E:\\Tom\\Documents\\GitHub\\UnityStars\\Build\\Windows\\"; string buildName = "UnityStars!"; // build for windows stand alone string windowsStandAloneBuildName = buildName + "-Standalone.exe"; EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows); BuildPipeline.BuildPlayer(scenes, path + windowsStandAloneBuildName, BuildTarget.StandaloneWindows, BuildOptions.None); path = "E:\\Dropbox\\Dropbox\\"; // build for Android string androidPlayerBuildName = buildName + "-Android.apk"; EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); BuildPipeline.BuildPlayer(scenes, path + androidPlayerBuildName, BuildTarget.Android, BuildOptions.None); }
public static void setVolumeFriendlyPrefs() { Debug.Log("Removing skybox..."); Debug.Log("Removing ambient light..."); //turn off ambient stuff, they can cause lighting anomalies of not specifically set or handled RenderSettings.skybox = null; RenderSettings.ambientLight = Color.black; Debug.Log("Ensuring editor set to 3D mode..."); EditorSettings.defaultBehaviorMode = EditorBehaviorMode.Mode3D; Debug.Log("Ensuring Scene views set to 3D mode..."); foreach (SceneView s in SceneView.sceneViews) { s.in2DMode = false; } Debug.Log("Setting compatibility level to .Net 2.0 (necessary for receiving input from Volume)..."); Debug.Log("Setting HYPERCUBE_INPUT preprocessor macro (necessary for receiving input from Volume)..."); //these 2 lines below MUST stay together!! If the preprocessor is added without changing the ApiCompatibilityLevel, then a weird error will appear where the editor won't know what IO.ports is //this will be very tough for novice programmers to figure out what is going on. PlayerSettings.apiCompatibilityLevel = ApiCompatibilityLevel.NET_2_0; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "HYPERCUBE_INPUT"); //add HYPERCUBE_INPUT to prerprocessor defines Debug.Log("Setting our standalone build target..."); #if UNITY_EDITOR_WIN if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows); } #elif UNITY_EDITOR_OSX if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneOSXUniversal) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneOSXUniversal); } #endif }
/// <summary> /// Build the app for iOS. /// </summary> private void BuildiOS() { SetupBuildVariables(); var startTime = DateTime.Now; _buildSettings.Apply(); EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); PlayerSettings.productName = _buildProductName; PlayerSettings.applicationIdentifier = _buildBundleIdentifier; #if !UNITY_5_6 PlayerSettings.virtualRealitySupported = false; #endif PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP); BuildPlatform(BuildTarget.iOS, _buildSettings.Scenes.ToArray(), BuildOptions.None); _buildSettings.Apply(); var totalTime = DateTime.Now - startTime; Debug.Log("Build time (iOS): " + totalTime.Minutes.ToString("00") + ":" + totalTime.Seconds.ToString("00")); }
static void ExportXcodeProject() { //#pragma warning disable CS0618 // Type or member is obsolete EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS); //#pragma warning restore CS0618 // Type or member is obsolete EditorUserBuildSettings.symlinkLibraries = false; EditorUserBuildSettings.development = false; EditorUserBuildSettings.allowDebugging = true; List <string> scenes = new List <string>(); for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) { if (EditorBuildSettings.scenes [i].enabled) { scenes.Add(EditorBuildSettings.scenes [i].path); } } BuildPipeline.BuildPlayer(scenes.ToArray(), "Platforms/iOS", BuildTarget.iOS, BuildOptions.None); }
private static void SwitchPlatformUnix(BuildTarget target) { if (Directory.Exists(target.ToString())) { RemoveLibrarySymbolicLinkUnix(); } else { CreateDirectoryUnix(target.ToString()); } Process process = new Process(); process.StartInfo.FileName = "ln"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.Arguments = string.Format("-s {0}/ Library", target.ToString()); process.Start(); process.WaitForExit(); process.Close(); EditorUserBuildSettings.SwitchActiveBuildTarget(target); }
//------------------------------------------------------------------------- void _packAssetBundleCompressAll(string target_path) { EditorUserBuildSettings.SwitchActiveBuildTarget(mCurrentBuildTargetPlatform); deleteFile(mTargetPlatformRootPath); Caching.CleanCache(); mListAllPkgSingleABFile.Clear(); _getAllPkgSingleFiles(mAssetBundleResourcesPkgSinglePath); mListAllPkgFoldABFold.Clear(); _getAllPkgFoldFold(mAssetBundleResourcesPkgFoldPath); _pakABSingle(); _pakABFold(); if (Directory.Exists(mRowAssetPath)) { copyFile(mRowAssetPath, target_path, "Assets/"); } Debug.Log("裸资源复制完毕!"); }