Unity2018.4送的Prefab Variant(Prefab變種)功能瞭解一下

Unity 2018.4中送了一個新的功能: Prefab Variant

思路是, Prefab Variant 繼承於一個父Prefab, 父Prefab屬性修改後:

(1)如果子Prefab的某些屬性不動, 則父Prefab的屬性影響子Prefab的屬性, 此爲 [屬性繼承]

(2)如果對子Prefab的某些屬性進行修改/覆蓋, 則父Prefab的屬性無法影響, 此爲 [屬性定製]

創建Prefab Variant的方法爲: 把Prefab從Hierarchy再次拉到Project中,選擇 Prefab Variant

用處舉例:

比如做一個UGUI窗體模板, 上面有標題文字和關閉按鈕

郵件窗體繼承於此窗體模板,製作成爲一個PrefabVariant, 但是標題文字定製修改爲"郵件"

這時,可以通過修改窗體模板中的關閉按鈕,對所有派生的窗體按鈕進行修改

 附:以下爲官方對PrefabAssetType的解釋:

    public enum PrefabAssetType
    {
 
        //
        // 摘要:
        //     The object being queried is not part of a Prefab at all.
        NotAPrefab = 0, // 不是Prefab
 
        //
        // 摘要:
        //     The object being queried is part of a regular Prefab.
        Regular = 1, // 常規的Prefab
 
        //
        // 摘要:
        //     The object being queried is part of a Model Prefab.
        Model = 2, // 模型(例如:FBX)
 
        //
        // 摘要:
        // The object being queried is part of a Prefab Variant.
        // A Variant Prefab is a Prefab that is derived from another Prefab, 
        // that be could be a Regular, Model or even Variant Prefab.
        Variant = 3, // Prefab變種
 
        //
        // 摘要:
        //     The object being queried is part of a Prefab instance, but because the asset
        //     it missing the actual type of Prefab can’t be determined.
        MissingAsset = 4 // Prefab實例化出來的對象,但是Prefab被刪了(紅色)
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章