Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't build the Asset Bundles when using HideFlags.DontSave on a prefab

Discussion in 'Asset Bundles' started by AdrienArt, Apr 12, 2021.

  1. AdrienArt

    AdrienArt

    Joined:
    May 4, 2020
    Posts:
    3
    Hello,
    The build of the asset bundles will always fail if any gameObject inside a prefab is flagged as "DontSave".
    Here is the error shown in the console:

    An asset is marked with HideFlags.DontSave but is included in the build:
    Asset: 'Assets/Bundle/NotSavedPrefab.prefab'
    Included from scene: 'Assets/Scenes/SampleScene.unity'
    Asset name: NotSavedPrefab
    (You are probably referencing internal Unity data in your build.)
    UnityEditor.BuildPipeline:BuildAssetBundles (string,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTarget)

    This is a useful flag that we use in the build to exclude gameObjects at build time depending on the platform.
    It works well in a normal build but prevent building if the gameObject is in an asset bundle.
    At first I thought it was a bug so I reported it, but I was told by the QA that it is the current design. They told me to ask for a change here on the forum.
    Would it be possible to make it work in the future?