1. 程式人生 > >GameFramework篇:AssetsBundle Tools配置

GameFramework篇:AssetsBundle Tools配置

我們從官網可以知道首次為一個專案編輯 AssetBundle 資源,需要先編輯配置檔案 Assets/GameFramework/Configs/AssetBundleEditor.xml

可是當我們回過頭來看StarForce案例卻發現,並沒有這個目錄

我們注意到,開啟工程會有這個Log(自己新建工程就會出現警告,載入失敗,應用預設路徑

追蹤進去

繼續順著Load追蹤

目標很明確了,m_ConfigurationPath

我們繼續追蹤會看到這樣一句

            m_ConfigurationPath = Type.GetConfigurationPath<AssetBundleEditorConfigPathAttribute>() ?? Utility.Path.GetCombinePath(Application.dataPath, "GameFramework/Configs/AssetBundleEditor.xml");

??用於定義可空型別和引用型別的預設值。如果此運算子的左運算元不為null,則此運算子將返回左運算元,否則返回右運算元。 例如:a??b 當a為null時則返回b,a不為null時則返回a本身。 空合併運算子為右結合運算子,即操作時從右向左進行組合的。如,“a??b??c”的形式按“a??(b??c)”計算。

所以很明確了,此配置檔案會先讀取

AssetBundleEditorConfigPathAttribute

我們跟進去最後發現這個

意為配置路徑的屬性,關於Attribute(屬性)不太瞭解的小夥伴可以看看https://www.cnblogs.com/ldyblogs/p/attribute.html

然後在加上AssetBundleEditorConfigPathAttribute屬性就可以配置AB編輯器的配置路徑了

對於新建的工程,Unity並不提供xml檔案的建立,所以需要大家自行解決。(瘋狂暗示rider)