InstantAsset 是團結引擎提供的全新資產工作流,通過直接復用資產導入結果,實現 “Import To Runtime” 的運行時資產管理方式。
請觀看資產免構建工作流的演示視頻:
傳統 AssetBundle 工作流的瓶頸
在團結/Unity項目開發中,AssetBundle 是目前最常見的資產管理方式之一,廣泛用于資產分發、熱更新與運行時加載。
但隨著項目規模增長,傳統 AssetBundle 工作流也會逐漸暴露一些問題,例如:
資產構建耗時較長
容易產生資產冗余
依賴關系管理復雜
尤其在資產頻繁變更的項目中,開發者往往需要頻繁等待 Bundle 構建完成,影響整體游戲迭代效率。
這些瓶頸的根源在于傳統工作流的設計:Artifact 只在編輯器內部使用,運行時必須重新構建 AssetBundle。如果運行時能直接使用 Artifact,這些耗時的構建步驟就可以省掉。針對這些問題,我們設計了 InstantAsset。
InstantAsset 方案概述
InstantAsset 是團結引擎提供的一套全新資產管理方案,核心思路是復用 Artifact 避免重復序列化,支持免構建模式運行。
傳統工作流中,資源導入后還需經過構建環節才能生成可供運行時使用的 AssetBundle 文件。InstantAsset 打通了編輯器導入結果與運行時資源系統之間的鏈路,資源在編輯器中正常導入后,即可直接在運行時使用,無需先構建 AssetBundle。
![]()
具體來說,InstantAsset 通過以下三個個關鍵設計實現:
復用 Artifact,省去重復序列化
基于 GUID 的運行時資產映射
基于 Accelerator 的 Runtime 資產服務層
核心機制
復用 Artifact,省去重復序列化
團結引擎在資源導入階段會生成對應的 Artifact(導入緩存)。傳統工作流中,這些 Artifact 僅在編輯器內部使用,運行時仍需重新序列化資產對象并構建 AssetBundle 數據。InstantAsset 可以運行時直接復用 Artifact 數據,避免對資產對象的重復序列化。資源導入完成后,無需再經過額外的序列化與構建環節,即可進入運行時加載流程。
需要注意的是,Shader、SpriteAtlas、VisualEffectAsset、ComputeShader 這幾類資產的 Artifact,運行時無法直接使用,仍需做完整的對象重新序列化。
基于 GUID 的運行時資產映射
為了支持運行時 Artifact 的依賴解析,InstantAsset 對資產引用機制進行了擴展。在編輯器側,系統通過 GUID 標識資產及其依賴關系;然而在傳統運行時,這類元數據通常會被剔除,導致運行時復用 Artifact 時遭遇引用解析失敗。為此,InstantAsset 在運行時完整保留了資產的 GUID 映射關系,實現了統一的資產引用管理與動態解析,同時也有效地避免了資產冗余問題。
基于 Accelerator 的 Runtime 資產服務層
InstantAsset 基于 Accelerator(Cache Server)實現了 Artifact 分發能力,并為 Runtime Player 封裝了 RESTful API(get-asset-info、get-artifact)。在免構建模式下,它替代了編輯器中 AssetDatabase 的部分功能(GUID→路徑映射、依賴查詢、資產定位等),使 Runtime Player 無需本地構建即可按需獲取 Artifact。統一編輯器和 Player 的資產元信息,簡化資源依賴關系管理。
使用指南
InstantAsset 主要包括 InstantAssetManager 和 InstantAssetTable 兩個重要的類。InstantAssetManager 是用于所有資產表和生命周期管理的單例管理器。InstantAssetTable 是具有優化內存表示的資產映射容器。
相關的接口文檔請參考 :
https://docs.unity.cn/cn/tuanjiemanual/ScriptReference/InstantAsset.html https://docs.unity.cn/cn/tuanjiemanual/ScriptReference/InstantAssetTable.html 文檔用于資產的加載和卸載等管理操作。免構建模式下需要配置 Cache server,業務層可以無需構建情況下實現資產和場景的管理。啟用 InstantAsset,開啟免構建模式
1. Project Settting 窗口的 Editor頁面中配置Cache Server,將 Cache Server-Mode 設為 Enabled,并配置開發機的局域網 IP(手機等設備需通過局域網 IP 訪問 Accelerator,不可使用 127.0.0.1),點擊 Check Connection 測試連通情況:
![]()
2. Project Settting窗口的Editor頁面中開啟Instant Assets相關功能,參考如下:
![]()
[1] 詳細技術原理:[InstantAsset 技術原理深度解析]
https://developer.unity.cn/projects/6a190f80edbc2a8ee22ec066
[2] 完整使用文檔:[InstantAsset 使用說明]:
https://docs.unity.cn/cn/tuanjiemanual/Manual/InstantAssetIntro.html
[3] 快速上手教程:[InstantAsset 快速入門]:
https://docs.unity.cn/cn/tuanjiemanual/Manual/InstantAsset-QuicklyStart.html
[4] 免構建快速上手教程:[InstantAsset 免構建快速入門]:
h ttps://docs.unity.cn/cn/tuanjiemanual/Manual/InstantAsset-QuicklyStart-DatalessPlayer.html
Unity 官方微信
第一時間了解Unity引擎動向,學習進階開發技能
每一個“點贊”、“在看”,都是我們前進的動力
![]()
![]()
特別聲明:以上內容(如有圖片或視頻亦包括在內)為自媒體平臺“網易號”用戶上傳并發布,本平臺僅提供信息存儲服務。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.