加載方式
Coding Style wiki
通過 Resources 加載
提醒 使用 Resources 加載時,不需要進行額外配置,僅將資源放在 Resources 下,並且直接使用 res# 作為前墜 + 資源路徑進行加載。

重要 使用 res# 作為前墜時,將會切換成 Resources 加載方式。
// res# prefix
AssetLoaders.LoadAssetAsync<GameObject>("res#MyPrefabs/Cube");
通過 AssetBundle 加載
步驟 1.
必須先通過 YooAsset Collector 配置。
注意 尋址名稱需要注意,圖中的 DefaultPackage 包含尋址名稱的有 Cube。

步驟 2.
另外使用 AssestBundle 進行開發時,也需要 PatchLauncher 進行 Runtime 配置,主要是使用 AssetBundle 加載時,需要初始相關配置。

注意 匯 入後拖曳到 Hierarchy 窗體。

步驟 3.
配置預設 Packages,將會在 Runtime 時進行初始。
- 預設 App Packages。
- 預設 DLC Packages。

重要 預設 Packages 將由主下載器進行管理與檢查,所以不包含在預設中的 Packages,必須自行通過 API 初始,說明如下。
App Package
// [Load asset and download from specific package (Export App Bundles for CDN)]
AppPackageInfoWithBuild packageInfo = new AppPackageInfoWithBuild()
{
buildMode = BundleConfig.BuildMode.ScriptableBuildPipeline,
packageName = "OtherPackage"
};
bool isInitialized = await AssetPatcher.InitAppPackage(packageInfo, true);
if (isInitialized)
await AssetLoaders.LoadAssetAsync<GameObject>("packageName", "assetName");
DLC Package
// [Load asset and download from specific package (Export Individual DLC Bundles for CDN)]
DlcPackageInfoWithBuild packageInfo = new DlcPackageInfoWithBuild()
{
buildMode = BundleConfig.BuildMode.ScriptableBuildPipeline,
packageName = "DlcPackage",
dlcVersion = "dlcVersion",
withoutPlatform = false
};
bool isInitialized = await AssetPatcher.InitDlcPackage(packageInfo, true);
if (isInitialized)
await AssetLoaders.LoadAssetAsync<GameObject>("packageName", "assetName");
注意 區分 App Packages 跟 DLC Packages,注意路徑不同。
- App Packages