Linux之whereis命令
1436
2025-04-01
AAB
Android App Bundle 是 Android 新推出的一種官方發布格式,可讓你以更高效的方式開發和發布應用。借助 Android App Bundle,你可以更輕松地以更小的應用提供優質的使用體驗,從而提升安裝成功率并減少卸載量。轉換過程輕松便捷。你無需重構代碼即可開始獲享較小應用的優勢。改用這種格式后,你可以體驗模塊化應用開發和可自定義功能交付,并從中受益。
Play Asset Delivery
Play Asset Delivery (PAD) 將 app bundle 的優勢帶到游戲中。它允許超過 150 MB 的游戲替換舊版擴展文件 (OBB),方法是將包含游戲所需的所有資源的單個工件發布到 Play。PAD 提供了靈活的分發模式、自動更新、壓縮和增量修補功能,并且可免費使用。使用 PAD,所有資源包均在 Google Play 上托管和提供,因此你無需使用內容分發網絡 (CDN) 向玩家提供游戲資源。
Play Asset Delivery 使用資源包,資源包由資源(如紋理、著色器和聲音)組成,但不包含可執行代碼。通過 Dynamic Delivery,你可以按照以下三種分發模式自定義如何以及何時將各個資源包下載到設備上:「安裝時分發」、「快速跟進式分發」和「按需分發」。
分發模式
「install-time」 資源包在用戶安裝應用時分發。這些資源包以拆分 APK(APK 集的一部分)的形式提供。它們也稱為“預先”資源包;您可以在應用啟動時立即使用這些資源包。這些資源包會增加 Google Play 商店上列出的應用大小。用戶無法修改或刪除這些資源包。
「fast-follow」 資源包會在用戶安裝應用后立即自動下載;用戶無需打開應用即可開始 fast-follow 下載。此類下載不會阻止用戶訪問應用。這些資源包會增加 Google Play 商店上列出的應用大小。
「on-demand」 資源包會在應用運行時下載。
Google Play 商店會以歸檔文件(而非拆分 APK)的形式提供配置為 fast-follow 和 on-demand 的資源包。這些資源包隨后會在應用的內部存儲空間中展開。您可以使用 Play Core API 查詢以這種方式提供的資源包的位置。應用無法假設這些文件的存在或其位置,因為它們可能會被用戶刪除,或由 Play Core SDK 在游戲會話之間移動。盡管這些文件可由應用寫入,您也應將其視為只讀文件,因為資源包補丁程序依賴于這些文件的完整性。
資源更新
更新應用時,「install-time」 Asset Pack 會作為基礎應用更新的一部分進行更新(開發者無需執行任何操作)。
對于 「fast-follow」 和 「on-demand」 Asset Pack 的應用更新,則遵循以下步驟:
1、系統將應用的補丁程序(包括所有資產)下載到設備上的安全位置。
2、更新應用二進制文件;這包括所有 install-time Asset Pack。
3、之前下載的所有 Asset Pack 變為無效。
4、將資產的補丁程序復制并應用到存儲在應用內部存儲空間中的資產。
在大多數情況下,當用戶打開游戲時,整體更新已完成,用戶可以立即開始玩更新后的版本。在極少數情況下,當用戶打開應用時,應用二進制文件可能已完成更新,但資產的補丁程序應用過程尚未完成,因此用戶尚無法訪問這些資產。為了應對此類情形,您需要針對這些資產提供相應的“正在更新”界面元素,或構建邏輯來處理尚無法訪問的無效資源。由于只有在所有 Asset Pack 類型均已下載后,應用二進制文件才會更新,因此補丁程序的應用操作會在本地以離線方式進行,且應快速完成。
紋理壓縮格式定位
紋理壓縮是一種有損圖像壓縮,可讓 GPU 使用專用硬件直接從壓縮紋理進行渲染,從而減少所需的紋理內存和內存帶寬用量。借助紋理壓縮格式定位功能,您可以在 Android App Bundle 中添加使用多種紋理壓縮格式壓縮的紋理,并且依靠 Google Play 自動為每種設備提供采用最佳紋理壓縮格式的資源。
應用版本更新
新版本的應用上傳到 Google Play 后,如果用戶未在設備上更新該應用,他們可以打開之前的應用版本。在這種情況下,如有必要,應用可以通過調用 In-App Updates API 選擇強制更新或建議更新。借助此 API,您可以從應用內觸發更新,而不是讓用戶從 Google Play 商店觸發更新。
下載大小上限
Asset Pack 因具有較高的大小上限而成為大型游戲的理想之選:
1、每個 fast-follow 和 on-demand Asset Pack 的下載大小上限為 512 MB。
2、所有 install-time Asset Pack 的總下載大小上限為 1 GB。
3、一個 Android App Bundle 中的所有 Asset Pack 的總下載大小上限為 2 GB。
4、一個 Android App Bundle 中最多可以使用 50 個資源包。
如果你使用的是紋理壓縮格式定位,那么這些下載限制會分別應用于每個獨一無二的紋理格式。
針對 Unity 構建
Unity?AssetBundle?文件包含可在應用程序運行時由 Unity 引擎加載的序列化資產。這些文件是特定于平臺的(例如,為 Android 構建)并且可以與資產包結合使用。最常見的是,?「一個 AssetBundle 文件被打包成一個資產包」,該包使用與 AssetBundle 相同的名稱。
1、獲取 Play Asset Delivery 的 Unity 插件(或包)。
「注意:」 Google Play 核心庫的下載和使用受Play 核心軟件開發工具包服務條款的約束。下載和使用 Google Play 核心庫,「即表示你同意 Play 核心軟件開發工具包服務條款」。
Unity 插件可用于精選的 Play 核心 API,包括 Play Asset Delivery。從Google Play Plugins for Unity 版本下載最新版本。這是一個包含 Play Core 插件以及其他 Play 插件(例如 Play In-app Billing 和 Play Instant)的單一軟件包。
2、在 Unity 中創建 AssetBundles。
「注意:」 你可以使用?Unity AssetBundle Browser?在你的 Unity 項目中創建和管理 AssetBundle。
使用 UI 配置 AssetBundles
1、在資產包中配置每個 AssetBundle:
選擇Google > Android App Bundle > Asset Delivery設置。
要選擇直接包含 AssetBundle 文件的文件夾,請單擊添加文件夾。
2、對于每個捆綁包,將Asset Delivery更改為「Install Time」、「Fast Follow」或「On Demand」。解決任何錯誤或依賴項并關閉窗口。
3、選擇Google > Build Android App Bundle以構建應用程序包。
4、(可選)配置你的應用程序包以支持不同的紋理壓縮格式。
常見的紋理壓縮格式:
DDS 或 S3TC:有時稱為 DXTC 或 DXTn。OpenGL 支持此格式的三種形式。
ETC1:大多數設備都支持此格式。這種格式不支持透明度,但游戲可將第二個紋理文件用于 Alpha 通道組件。
ETC2:支持 GLES3 的所有設備均支持此格式。
PVRTC:iOS 游戲常用的格式,在某些 Android 設備上也受支持。
ASTC:專為取代之前的格式而設計的新格式。比先前的格式更加靈活,因為它支持各種塊大小。使用這種格式可以幫助您優化游戲大小。
支持的格式及支持相應格式設備所占的百分比:
使用 API 配置資產包
你可以通過編輯器腳本配置資產交付,這些腳本可以作為自動構建系統的一部分運行。
使用 AssetPackConfig 該類來定義要包含在 Android App Bundle 構建中的資產,以及模式。這些資產包不需要包含 AssetBundle。
public?void?ConfigureAssetPacks?{
//?Creates?an?AssetPackConfig?with?a?single?asset?pack,?named
//?examplePackName,?containing?all?the?files?in?path/to/exampleFolder.
var?assetPackConfig?=?new?AssetPackConfig();
assetPackConfig.AddAssetsFolder("examplePackName",
"path/to/exampleFolder",
AssetPackDeliveryMode.OnDemand);
//?Configures?the?build?system?to?use?the?newly?created?assetPackConfig?when
//?calling?Google?>?Build?and?Run?or?Google?>?Build?Android?App?Bundle.
AssetPackConfigSerializer.SaveConfig(assetPackConfig);
//?Alternatively,?use?BundleTool.BuildBundle?to?build?an?App?Bundle?from?script.
BuildBundle(new?buildPlayerOptions(),?assetPackConfig);
}
你還可以使用類中的靜態 BuildBundle 方法Bundletool生成帶有資產包的 Android App Bundle,給定 「BuildPlayerOptions」 和 「AssetPackConfig」。
Play Asset Delivery Unity API 集成
該 「Play Asset Delivery Unity API」 提供了請求資產包,下載管理,和訪問資源的功能。「確保」首先將 Unity 插件添加到你的項目中。
你在 API 中使用的函數取決于你創建資產包的方式。
如果你使用 UI 配置 AssetBundles,請「選擇插件配置的資產包」。
如果你使用 API 配置資產包,請選「擇API 配置的資產包」。
你可以根據要訪問的資產包的交付類型實施 API。這些步驟顯示在以下流程圖中。
檢索 AssetBundles
導入 Play Asset Delivery API 并調用該 RetrieveAssetBundleAsync()方法來檢索 AssetBundle。
using?Google.Play.AssetDelivery;
//?Loads?the?AssetBundle?from?disk,?downloading?the?asset?pack?containing?it?if?necessary.
PlayAssetBundleRequest?bundleRequest?=?PlayAssetDelivery.RetrieveAssetBundleAsync(asset-bundle-name);
安裝時交貨
資產包配置為「install-time」在應用程序啟動時立即可用。你可以使用以下命令從 AssetBundle 加載場景:
AssetBundle?assetBundle?=?bundleRequest.AssetBundle;
//?You?may?choose?to?load?scenes?from?the?AssetBundle.?For?example:
string[]?scenePaths?=?assetBundle.GetAllScenePaths();
SceneManager.LoadScene(scenePaths[path-index]);
快速跟進和按需交付
這些部分適用于「fast-follow」和「on-demand」資產包。
檢查狀態
每個資產包都存儲在應用程序內部存儲的單獨文件夾中。使用該 「isDownloaded()」 方法確定是否已下載資產包。
監控下載
查詢PlayAssetBundleRequest 監控請求狀態的 對象:
//?Download?progress?of?request,?between?0.0f?and?1.0f.?The?value?will?always?be
//?1.0?for?assets?delivered?as?install-time.
//?NOTE:?A?value?of?1.0?will?only?signify?the?download?is?complete.?It?will?still?need?to?be?loaded.
float?progress?=?bundleRequest.DownloadProgress;
//?Returns?true?if:
//???*?it?had?either?completed?the?download,?installing,?and?loading?of?the?AssetBundle,
//???*?OR?if?it?has?encountered?an?error.
bool?done?=?bundleRequest.IsDone;
//?Returns?status?of?retrieval?request.
AssetDeliveryStatus?status?=?bundleRequest.Status;
switch(status)?{
case?AssetDeliveryStatus.Pending:
//?Asset?pack?download?is?pending?-?N/A?for?install-time?assets.
case?AssetDeliveryStatus.Retrieving:
//?Asset?pack?is?being?downloaded?and?transferred?to?app?storage.
//?N/A?for?install-time?assets.
case?AssetDeliveryStatus.Available:
//?Asset?pack?is?downloaded?on?disk?but?NOT?loaded?into?memory.
//?For?PlayAssetPackRequest(),?this?indicates?that?the?request?is?complete.
case?AssetDeliveryStatus.Loading:
//?Asset?pack?is?being?loaded.
case?AssetDeliveryStatus.Loaded:
//?Asset?pack?has?finished?loading,?assets?can?now?be?loaded.
//?For?PlayAssetBundleRequest(),?this?indicates?that?the?request?is?complete.
case?AssetDeliveryStatus.Failed:
//?Asset?pack?retrieval?has?failed.
case?AssetDeliveryStatus.WaitingForWifi:
//?Asset?pack?retrieval?paused?until?either?the?device?connects?via?Wi-Fi,
//?or?the?user?accepts?the?PlayAssetDelivery.ShowCellularDataConfirmation?dialog.
default:
break;
}
大量下載
大于 150MB 的資產包可以自動下載,但只能通過 Wi-Fi 下載。如果用戶未連接到 Wi-Fi,則PlayAssetBundleRequest狀態設置為 AssetDeliveryStatus.WaitingForWifi 并暫停下載。在這種情況下,要么等待設備連接到 Wi-Fi,然后繼續下載,要么提示用戶批準通過蜂窩連接下載包。
if(bundleRequest.Status?==?AssetDeliveryStatus.WaitingForWifi)?{
var?userConfirmationOperation?=?PlayAssetDelivery.ShowCellularDataConfirmation();
yield?return?userConfirmationOperation;
switch(userConfirmationOperation.GetResult())?{
case?ConfirmationDialogResult.Unknown:
//?userConfirmationOperation?finished?with?an?error.?Something?went
//?wrong?when?displaying?the?prompt?to?the?user,?and?they?weren't
//?able?to?interact?with?the?dialog.?In?this?case,?we?recommend
//?developers?wait?for?Wi-Fi?before?attempting?to?download?again.
//?You?can?get?more?info?by?calling?GetError()?on?the?operation.
case?ConfirmationDialogResult.Accepted:
//?User?accepted?the?confirmation?dialog?-?download?will?start
//?automatically?(no?action?needed).
case?ConfirmationDialogResult.Declined:
//?User?canceled?or?declined?the?dialog.?Await?Wi-Fi?connection,?or
//?re-prompt?the?user.
default:
break;
}
}
取消請求(僅限按需)
如果需要在 AssetBundles 加載到內存之前取消請求,請調用 對象AttemptCancel() 上的方法 PlayAssetBundleRequest:
//?Will?only?attempt?if?the?status?is?Pending,?Retrieving,?or?Available?-?otherwise
//?it?will?be?a?no-op.
bundleRequest.AttemptCancel();
//?Check?to?see?if?the?request?was?successful?by?checking?if?the?error?code?is?Canceled.
if(bundleRequest.Error?==?AssetDeliveryErrorCode.Canceled)?{
//?Request?was?successfully?canceled.
}
異步請求資產包
在大多數情況下,你應該使用 Coroutines異步請求資產包并監控進度,如下所示:
private?IEnumerator?LoadAssetBundleCoroutine(string?assetBundleName)?{
PlayAssetBundleRequest?bundleRequest?=
PlayAssetDelivery.RetrieveAssetBundleAsync(assetBundleName);
while?(!bundleRequest.IsDone)?{
if(bundleRequest.Status?==?AssetDeliveryStatus.WaitingForWifi)?{
var?userConfirmationOperation?=?PlayAssetDelivery.ShowCellularDataConfirmation();
//?Wait?for?confirmation?dialog?action.
yield?return?userConfirmationOperation;
if((userConfirmationOperation.Error?!=?AssetDeliveryErrorCode.NoError)?||
(userConfirmationOperation.GetResult()?!=?ConfirmationDialogResult.Accepted))?{
//?The?user?did?not?accept?the?confirmation?-?handle?as?needed.
}
//?Wait?for?Wi-Fi?connection?OR?confirmation?dialog?acceptance?before?moving?on.
yield?return?new?WaitUntil(()?=>?bundleRequest.Status?!=?AssetDeliveryStatus.WaitingForWifi);
}
//?Use?bundleRequest.DownloadProgress?to?track?download?progress.
//?Use?bundleRequest.Status?to?track?the?status?of?request.
yield?return?null;
}
if?(bundleRequest.Error?!=?AssetDeliveryErrorCode.NoError)?{
//?There?was?an?error?retrieving?the?bundle.?For?error?codes?NetworkError
//?and?InsufficientStorage,?you?may?prompt?the?user?to?check?their
//?connection?settings?or?check?their?storage?space,?respectively,?then
//?try?again.
yield?return?null;
}
//?Request?was?successful.?Retrieve?AssetBundle?from?request.AssetBundle.
AssetBundle?assetBundle?=?bundleRequest.AssetBundle;
其他 Play Core API 方法
以下是你可能希望在應用中使用的一些其他 API 方法。
檢查下載大小
通過對 Google Play 進行異步調用并設置操作完成時的回調方法來檢查 AssetBundle 的大小:
public?IEnumerator?GetDownloadSize()?{
PlayAsyncOperation
PlayAssetDelivery.GetDownloadSize(assetPackName);
yield?return?getSizeOperation;
if(operation.Error?!=?AssetDeliveryErrorCode.NoError)?{
//?Error?while?retrieving?download?size.
}?else?{
//?Download?size?is?given?in?bytes.
long?downloadSize?=?operation.GetResult();
}
}
移除 AssetBundles
你可以刪除當前未加載到內存中的快速關注和按需 AssetBundle。進行以下異步調用并設置完成時的回調方法:
PlayAsyncOperation
removeOperation.Completed?+=?(operation)?=>
{
if(operation.Error?!=?AssetDeliveryErrorCode.NoError)?{
//?Error?while?attempting?to?remove?AssetBundles.
}?else?{
//?Files?were?deleted?OR?files?did?not?exist?to?begin?with.
}
};
測試
在 Unity Editor 中,選擇Google > Build and Run。
行為
「install-time」 包將在應用程序安裝過程中安裝。
「fast-follow」包的行為與「on-demand」包一樣。也就是說,當游戲被側載時它們不會被自動獲取。開發者需要在游戲開始時手動請求;這不需要你的應用程序中的任何代碼更改。
限制
以下是本地測試的限制:
Packs 從外部存儲而不是 Play 中獲取,因此您無法測試您的代碼在出現網絡錯誤的情況下的行為。
本地測試不包括等待 Wi-Fi 場景。
不支持更新。在安裝新版本的構建之前,請手動卸載以前的版本。
使用內部應用共享進行測試
當你接近發布候選版本時,請使用盡可能真實的配置來測試你的游戲,以確保你的游戲在生產環境中為您的用戶提供良好的性能。 構建您的應用程序包。
要使用內部應用程序共享測試資產交付,請執行以下操作:
構建你的應用程序包。
按照 Play 管理中心的說明進行操作,了解如何在 內部共享您的應用。
在測試設備上,單擊您剛剛上傳的應用程序版本的內部應用程序共享鏈接。
從點擊鏈接后看到的 Google Play 商店頁面安裝應用程序。
搞定齊活。
相關推薦
Android aab打包
App Bundle介紹
打包AAB+PAD(java篇)
AAB打包報錯
Google Pay接入
Android iOS unity
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。