Firstborn/Library/PackageCache/com.unity.addressables@1.19.19/Tests/Editor/DocExampleCode/BatchBuild.cs
Schaken-Mods 7502018d20 Adding Mod Support
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
2023-05-13 22:01:48 -05:00

59 lines
2.2 KiB
C#

namespace AddressableAssets.DocExampleCode
{
#region doc_BatchBuild
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Build;
using UnityEditor.AddressableAssets.Settings;
using UnityEditor.Build.Reporting;
using UnityEngine;
internal class BatchBuild
{
public static string build_script
= "Assets/AddressableAssetsData/DataBuilders/BuildScriptPackedMode.asset";
public static string profile_name = "Default";
public static void ChangeSettings() {
string defines = "";
string[] args = Environment.GetCommandLineArgs();
foreach (var arg in args)
if (arg.StartsWith("-defines=", System.StringComparison.CurrentCulture))
defines = arg.Substring(("-defines=".Length));
var buildSettings = EditorUserBuildSettings.selectedBuildTargetGroup;
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildSettings, defines);
}
public static void BuildContentAndPlayer() {
AddressableAssetSettings settings
= AddressableAssetSettingsDefaultObject.Settings;
settings.activeProfileId
= settings.profileSettings.GetProfileId(profile_name);
IDataBuilder builder
= AssetDatabase.LoadAssetAtPath<ScriptableObject>(build_script) as IDataBuilder;
settings.ActivePlayerDataBuilderIndex
= settings.DataBuilders.IndexOf((ScriptableObject)builder);
AddressableAssetSettings.BuildPlayerContent(out AddressablesPlayerBuildResult result);
if (!string.IsNullOrEmpty(result.Error))
throw new Exception(result.Error);
BuildReport buildReport
= BuildPipeline.BuildPlayer(EditorBuildSettings.scenes,
"d:/build/winApp.exe", EditorUserBuildSettings.activeBuildTarget,
BuildOptions.None);
if (buildReport.summary.result != BuildResult.Succeeded)
throw new Exception(buildReport.summary.ToString());
}
}
#endif
#endregion
}