Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question When select texturetype to sprite, duplicate assets in bundles, How to solve?

Discussion in 'Asset Bundles' started by EP-Toushirou, Nov 22, 2021.

  1. EP-Toushirou

    EP-Toushirou

    Joined:
    Nov 19, 2019
    Posts:
    38
    Unity version:2020.3.23f1

    Ready: a picture and a RawImage Prefab dependent on the picture
    upload_2021-11-22_14-45-38.png

    A Build Script:
    public static class BuildAssetBundle
    {
    [MenuItem("BuildAssetBundle/Start")]
    static void Build()
    {
    List<AssetBundleBuild> assetBundleBuilds = new List<AssetBundleBuild>();

    AssetBundleBuild textureBundle = new AssetBundleBuild
    {
    assetBundleName = "texture.unity3d",
    assetNames = new string[]{
    "Assets/Texture/texture.jpg",
    }
    };
    assetBundleBuilds.Add(textureBundle);

    AssetBundleBuild prefabBundle = new AssetBundleBuild
    {
    assetBundleName = "prefab.unity3d",
    assetNames = new string[]{
    "Assets/Prefab/RawImage.prefab",
    }
    };
    assetBundleBuilds.Add(prefabBundle);

    BuildPipeline.BuildAssetBundles(
    "AssetBundles",
    assetBundleBuilds.ToArray(),
    BuildAssetBundleOptions.ChunkBasedCompression | BuildAssetBundleOptions.AppendHashToAssetBundleName,
    EditorUserBuildSettings.activeBuildTarget
    );
    }
    }

    First:Build with default texture type upload_2021-11-22_14-46-17.png

    this is what i want: upload_2021-11-22_14-48-14.png


    Second:Build with Sprite type: upload_2021-11-22_14-48-52.png
    (Delete all assetBundles file, rebuild here)

    upload_2021-11-22_14-50-36.png

    the texture is include in the prefab bundle!!! And when I load the RawImange GameObject, it will use the prefab bundle's texture, i change the texture(sprite type) and build the bundle will not show correct, because build assetbundle only change the texture bundle.

    and when I change to default type and build again(this time not delete the bundles), the prefab bundle doesn't change back to small size, because the dependies is the same.

    Is it normal ? or it is a bug?

    How to solve this?

    Thanks.
     
  2. EP-Toushirou

    EP-Toushirou

    Joined:
    Nov 19, 2019
    Posts:
    38
    I test Scritable Build Pipeline with (CompatibilityBuildPipeline.BuildAssetBundles) and it has not problem
     
  3. wgqing

    wgqing

    Joined:
    Feb 28, 2022
    Posts:
    1
    CompatibilityBuildPipeline.BuildAssetBundles confirm OK
    upload_2022-8-18_18-1-43.png
    WipeGlass has mat ,mat dependence T_meinvtest.png