Skip to main content
Version: v3

BundleConfig

Important Attention Reminder

Coding Style wiki


BundleConfig is the runtime core settings and utility class of the AssetLoader module. It centralizes static settings such as the play mode (PlayMode) and download/load options, and provides utility methods for parsing the deployment config (CdnConfig), composing CDN endpoint URLs, and locating local/built-in paths.

NamespaceOxGFrame.AssetLoader.Bundle
Typepublic static class
SourceBundleConfig.cs
using OxGFrame.AssetLoader.Bundle;

Reminder In most cases, the play mode and preset packages are configured on the PatchLauncher component in the scene (Inspector) and written into the corresponding BundleConfig fields automatically at startup — no manual assignment is needed.

Enums

PlayMode

public enum PlayMode
{
EditorSimulateMode,
OfflineMode,
HostMode,
WeakHostMode,
WebGLMode,
WebGLRemoteMode,
CustomMode
}

Asset runtime play mode.

NameValueDescription
EditorSimulateMode0Editor simulate mode. Simulates asset loading directly in the editor without actually building bundles (development only).
OfflineMode1Offline mode. Runs with the built-in assets shipped in the player only; no remote updates.
HostMode2Host mode. Checks versions and downloads updated assets from the host server (CDN).
WeakHostMode3Weak-host (weak network) mode. Based on host mode; when the network is unavailable, it can fall back to the last locally recorded versions and keep running (works with the enableLastLocalVersionsCheckInWeakNetwork parameter).
WebGLMode4WebGL mode. Runs with the built-in assets hosted on the web server only.
WebGLRemoteMode5WebGL remote mode. Supports downloading updated assets from a remote server (CDN).
CustomMode6Custom mode. Configure the runtime pipeline yourself via YooAsset initialize parameters (automatic preset-package initialization is not supported).

BuildMode

public enum BuildMode
{
BuiltinBuildPipeline = 1,
ScriptableBuildPipeline = 0,
RawFileBuildPipeline = 2,
#if YOOASSET_3
ArchiveFileBuildPipeline = 3
#endif
}

Asset build pipeline mode.

NameValueDescription
ScriptableBuildPipeline0Scriptable Build Pipeline (SBP).
BuiltinBuildPipeline1Built-in Build Pipeline.
RawFileBuildPipeline2Raw File Build Pipeline.
ArchiveFileBuildPipeline3Archive File Build Pipeline. YooAsset v3 only (YOOASSET_3).

Reminder YOOASSET_2 / YOOASSET_3 are defined automatically by the framework from the installed YooAsset version (no manual setup). See YooAsset Version Compatibility for the full comparison.

Reminder The buildMode setting on preset packages only takes effect in EditorSimulateMode.

CryptogramType Constants

public class CryptogramType
{
public const string NONE = "NONE";
public const string OFFSET = "OFFSET";
public const string XOR = "XOR";
public const string HT2XOR = "HT2XOR";
public const string HT2XORPLUS = "HT2XORPLUS";
public const string AES = "AES";
public const string CHACHA20 = "CHACHA20";
public const string XXTEA = "XXTEA";
public const string OFFSETXOR = "OFFSETXOR";
}

Cryptogram type identifiers, used to compose decryption argument strings (e.g., the Decrypt Info settings on PatchLauncher; identifiers are case-insensitive):

ConstantValueDecrypt Args Format
NONE"NONE"NONE (no encryption)
OFFSET"OFFSET"OFFSET, dummySize
XOR"XOR"XOR, key
HT2XOR"HT2XOR"HT2XOR, hKey, tKey, jKey
HT2XORPLUS"HT2XORPLUS"HT2XORPLUS, hKey, tKey, j1Key, j2Key
AES"AES"AES, key, iv
CHACHA20"CHACHA20"CHACHA20, key, nonce, counter
XXTEA"XXTEA"XXTEA, key
OFFSETXOR"OFFSETXOR"OFFSETXOR, key, dummySize

Static Fields

Play Mode & Preset Packages

NameTypeDefaultDescription
playModePlayModePlayMode.EditorSimulateModeCurrent play mode. Written by PatchLauncher at startup based on its Inspector settings.
playModeParametersPlayModeParametersnullParameter configuration of the current play mode. Assigned by PatchLauncher according to the play mode.
listAppPackagesList<AppPackageInfoWithBuild>nullApp preset package list. Written by PatchLauncher.
listDlcPackagesList<DlcPackageInfoWithBuild>nullDLC preset package list. Written by PatchLauncher.

Download Options

NameTypeDefaultDescription
maxConcurrencyDownloadCountint10Maximum concurrent download count. Used as the default concurrency when creating downloaders.
failedRetryCountint3Retry count on download failure. Used as the default retry count when creating downloaders.
breakpointFileSizeThresholduint20971520
(20 MB)
Breakpoint-resume threshold (bytes). Files reaching this size are downloaded with resumable download (maps to the YooAsset file system parameter RESUME_DOWNLOAD_MINMUM_SIZE).
DEFAULT_DOWNLOAD_WATCHDOG_TIMEOUTint30Default value of downloadWatchdogTimeout.
downloadWatchdogTimeoutint30Downloader watchdog timeout. If no download data is received within the monitored time range, the download task is terminated (maps to the YooAsset file system parameter DOWNLOAD_WATCH_DOG_TIME).

Load Options

NameTypeDefaultDescription
bundleLoadReadBufferSizeuint32768
(32 KB)
Read buffer size for bundle loading (AssetBundle.LoadFromStream).
bundleDecryptReadBufferSizeuint32768
(32 KB)
Read buffer size for bundle decryption.
autoUnloadBundleWhenUnusedboolfalseAutomatically releases asset bundles when their reference count reaches zero (maps to YooAsset AutoUnloadBundleWhenUnused).

Process Options

NameTypeDefaultDescription
operationSystemMaxTimeSlicelong30Maximum time slice consumed per frame by the async operation system (milliseconds; applied via YooAssets.SetOperationSystemMaxTimeSlice).
Attention
  • autoUnloadBundleWhenUnused, breakpointFileSizeThreshold, downloadWatchdogTimeout, and operationSystemMaxTimeSlice are applied to YooAsset during the package initialization phase — set them before the initialization flow if you need to adjust them.
  • maxConcurrencyDownloadCount and failedRetryCount are read each time a downloader is created.

Method Overview

Bundle URL Config

MethodDescription
GetValueFromUrlCfgGets the value of a key from the deployment config (CdnConfig), with automatic encryption detection and decryption.
GetAppStoreLinkGets the app store link (store_link).
GoToAppStoreOpens the app store page in the system browser.

AppConfig Access

MethodDescription
GetAppConfigFromStreamingAssetsReads the AppConfig from the built-in StreamingAssets.
GetAppConfigFromHostServerDownloads the AppConfig from the host server (with weak-network fallback).

Host Server Endpoints

MethodDescription
GetHostServerUrlComposes the remote download endpoint URL of an app package.
GetFallbackHostServerUrlComposes the fallback download endpoint URL of an app package.
GetDlcHostServerUrlComposes the remote download endpoint URL of a DLC package.
GetDlcFallbackHostServerUrlComposes the fallback download endpoint URL of a DLC package.
GetHostServerAppConfigPathGets the full URL of the AppConfig on the remote server.
GetHostServerPatchConfigPathGets the full URL of the PatchConfig on the remote server.

Local & Built-in Paths

MethodDescription
GetLocalSandboxRootPathGets the root path of local persistent assets (sandbox).
GetLocalSandboxPackagePathGets the local persistent path of a specific package.
GetBuiltinRootPathGets the root path of built-in assets.
GetBuiltinPackagePathGets the built-in path of a specific package.
GetLocalSandboxAppConfigPathGets the full AppConfig path inside the local sandbox.
GetStreamingAssetsAppConfigPathGets the full AppConfig path inside StreamingAssets.
GetRequestStreamingAssetsPathGets the StreamingAssets path suitable for UnityWebRequest.

Header Helper

MethodDescription
WriteInt16Writes a 16-bit integer into a buffer (little-endian).
ReadInt16Reads a 16-bit integer from a buffer.

GetValueFromUrlCfg

public static async UniTask<string> GetValueFromUrlCfg(string key)

Parameters

ParameterTypeDescription
keystringKey name in the deployment config. The constants PatchSettings.BUNDLE_IP, PatchSettings.BUNDLE_FALLBACK_IP, and PatchSettings.STORE_LINK can be used.

Returns

UniTask<string> — the value of the key; string.Empty if the config content is empty; null if the key is not found.

Description

Reads the deployment config from the built-in StreamingAssets (the file name is determined by PatchSettings, CdnConfig.dat by default) and parses its key-value data. The parsed result is cached after the first read.

Attention The file header is detected automatically: if the first 2 bytes match the cipher mark PatchSettings.CIPHER_HEADER, the content is decrypted with the PatchSettings.settings.bundleUrlCfgCipher key before parsing.

Example

// Get the primary CDN address (bundle_ip)
string host = await BundleConfig.GetValueFromUrlCfg(PatchSettings.BUNDLE_IP);

public static async UniTask<string> GetAppStoreLink()

Returns

UniTask<string> — the app store link (the value of the store_link key in the deployment config); null if not found.

Description

Gets the app store link from the deployment config (PatchSettings.STORE_LINK).


GoToAppStore

public static async UniTaskVoid GoToAppStore()

Description

Gets the store link (GetAppStoreLink) and opens the app store page (Google Play / App Store) in the system browser via Application.OpenURL. Commonly used in force-update flows. Returns UniTaskVoid (fire-and-forget, no need to await).

Example

// The app version is outdated — guide the player to the store to update
BundleConfig.GoToAppStore().Forget();

GetAppConfigFromStreamingAssets

public static async UniTask<AppConfig> GetAppConfigFromStreamingAssets()

Returns

UniTask<AppConfig> — the built-in AppConfig; null if it cannot be read.

Description

Reads the AppConfig (default AppInfo.json) from the built-in StreamingAssets. It contains PLATFORM, PRODUCT_NAME, APP_VERSION, and SEMANTIC_RULE. The result is cached after the first read.


GetAppConfigFromHostServer

public static async UniTask<AppConfig> GetAppConfigFromHostServer()

Returns

UniTask<AppConfig> — the AppConfig from the host server; null if it cannot be obtained.

Description

Downloads the latest AppConfig from the host server (used for version comparison and composing the latest version path). The result is cached after the first read.

Attention If the download fails and weak-network handling is enabled (playModeParameters.enableLastLocalVersionsCheckInWeakNetwork, weak-host mode only), it falls back to the last successfully stored version data on the local device.


GetHostServerUrl

public static async UniTask<string> GetHostServerUrl(string packageName)

Parameters

ParameterTypeDescription
packageNamestringPackage name.

Returns

UniTask<string> — the remote download endpoint URL of the app package.

Description

Composes the download endpoint of an app package based on the latest AppConfig from the host server, in the following format:

<bundle_ip>/<rootFolderName>/<PRODUCT_NAME>/<PLATFORM>/<vX.Y[.Z]>/<packageName>

Reminder The version folder format is determined by the SEMANTIC_RULE of the AppConfig: with PATCH enabled it is v<Major>.<Minor>.<Patch> (e.g., v1.0.0); otherwise v<Major>.<Minor> (e.g., v1.0).

Example

string url = await BundleConfig.GetHostServerUrl("DefaultPackage");
// e.g., http://127.0.0.1/CDN/MyProduct/StandaloneWindows64/v1.0/DefaultPackage

GetFallbackHostServerUrl

public static async UniTask<string> GetFallbackHostServerUrl(string packageName)

Parameters

ParameterTypeDescription
packageNamestringPackage name.

Returns

UniTask<string> — the fallback download endpoint URL of the app package.

Description

Same as GetHostServerUrl, but composes the path with the fallback address (bundle_fallback_ip).


GetDlcHostServerUrl

public static async UniTask<string> GetDlcHostServerUrl(string packageName, string dlcVersion, bool withoutPlatform = false)

Parameters

ParameterTypeDescription
packageNamestringDLC package name.
dlcVersionstringDLC version (DLC packages have their own version path, independent from the app version).
withoutPlatformboolWhether to omit the platform level in the path.
Default: false

Returns

UniTask<string> — the remote download endpoint URL of the DLC package.

Description

Composes the download endpoint of a DLC package in the following format:

<bundle_ip>/<rootFolderName>/<PRODUCT_NAME>/<PLATFORM>/<dlcFolderName>/<packageName>/<dlcVersion>

When withoutPlatform is true, the <PLATFORM> level is omitted.

Example

string url = await BundleConfig.GetDlcHostServerUrl("Dlc01Package", "1.0.0");
// e.g., http://127.0.0.1/CDN/MyProduct/StandaloneWindows64/DLC/Dlc01Package/1.0.0

GetDlcFallbackHostServerUrl

public static async UniTask<string> GetDlcFallbackHostServerUrl(string packageName, string dlcVersion, bool withoutPlatform = false)

Parameters

ParameterTypeDescription
packageNamestringDLC package name.
dlcVersionstringDLC version.
withoutPlatformboolWhether to omit the platform level in the path.
Default: false

Returns

UniTask<string> — the fallback download endpoint URL of the DLC package.

Description

Same as GetDlcHostServerUrl, but composes the path with the fallback address (bundle_fallback_ip).


GetHostServerAppConfigPath

public static async UniTask<string> GetHostServerAppConfigPath()

Returns

UniTask<string> — the full URL of the AppConfig on the remote server.

Description

Composes the URL of the AppConfig on the asset server (<bundle_ip>/<rootFolderName>/<PRODUCT_NAME>/<PLATFORM>/ plus the AppConfig file name, AppInfo.json by default).

Important The built-in AppConfig (StreamingAssets) is read first to determine the current product name and platform, then the remote request path is composed.


GetHostServerPatchConfigPath

public static async UniTask<string> GetHostServerPatchConfigPath()

Returns

UniTask<string> — the full URL of the PatchConfig on the remote server.

Description

Composes the URL of the PatchConfig on the asset server (<bundle_ip>/<rootFolderName>/<PRODUCT_NAME>/<PLATFORM>/ plus the PatchConfig file name, PatchInfo.json by default).

Important The built-in AppConfig (StreamingAssets) is read first to determine the current product name and platform, then the remote request path is composed.


GetLocalSandboxRootPath

public static string GetLocalSandboxRootPath()

Returns

string — the root path of local persistent assets (sandbox).

Description

Gets the root directory for local persistence (download storage), i.e., YooAsset's default cache file root (obtained via YooAssetBridge reflection).


GetLocalSandboxPackagePath

public static string GetLocalSandboxPackagePath(string packageName)

Parameters

ParameterTypeDescription
packageNamestringPackage name.

Returns

string — the local persistent path of the specified package (where downloaded content is stored).

Description

Combines GetLocalSandboxRootPath with the package name to form the local storage path of the package.


GetBuiltinRootPath

public static string GetBuiltinRootPath()

Returns

string — the root path of built-in assets.

Description

Gets YooAsset's default built-in file root directory (under StreamingAssets, obtained via YooAssetBridge reflection).


GetBuiltinPackagePath

public static string GetBuiltinPackagePath(string packageName)

Parameters

ParameterTypeDescription
packageNamestringPackage name.

Returns

string — the built-in path of the specified package.

Description

Combines GetBuiltinRootPath with the package name to form the built-in asset path of the package.


GetLocalSandboxAppConfigPath

public static string GetLocalSandboxAppConfigPath()

Returns

string — the full AppConfig path inside the local sandbox.

Description

Gets the full path of the AppConfig inside the local sandbox (the download storage path; file name AppInfo.json by default).


GetStreamingAssetsAppConfigPath

public static string GetStreamingAssetsAppConfigPath()

Returns

string — the full AppConfig path inside StreamingAssets.

Description

Gets the full path of the AppConfig inside the built-in StreamingAssets (composed from GetRequestStreamingAssetsPath, suitable for UnityWebRequest reads).


GetRequestStreamingAssetsPath

public static string GetRequestStreamingAssetsPath()

Returns

string — the StreamingAssets path suitable for UnityWebRequest.

Description

Gets the StreamingAssets path suitable for UnityWebRequest requests.

Attention On OSX (Standalone) and iOS, the file:// protocol prefix is appended automatically.


WriteInt16

public static void WriteInt16(short value, byte[] buffer, ref int pos)

Parameters

ParameterTypeDescription
valueshortThe 16-bit integer to write.
bufferbyte[]Target buffer.
posref intWrite position (advanced by 2 after writing).

Description

Writes a 16-bit integer into the buffer in little-endian byte order. Mainly used to write the cipher header (PatchSettings.CIPHER_HEADER) of the deployment config.


ReadInt16

public static short ReadInt16(byte[] buffer, ref int pos)

Parameters

ParameterTypeDescription
bufferbyte[]Source buffer.
posref intRead position (advanced by 2 after reading).

Returns

short — the 16-bit integer read from the buffer.

Description

Reads a 16-bit integer from the current position of the buffer (byte order determined by BitConverter.IsLittleEndian). Mainly used to detect the cipher header of the deployment config.