Search Unity

How to unpack prefabs when building scene bundles

Discussion in 'Asset Bundles' started by AlexeyDrobyshevsky, Oct 24, 2019.

  1. AlexeyDrobyshevsky

    AlexeyDrobyshevsky

    Joined:
    Sep 28, 2016
    Posts:
    37
    I have a bunch of scenes that I want in bundles. The scenes contain some prefabs, and by default, the prefab gets built in one bundle, with other scenes having that bundle as a dependency. Makes sense, but I would prefer if each scene bundle has no dependencies - the size gains are minuscule, and managing dependencies becomes WAY easier.

    If I manually unpack all prefabs in the scenes, this does what I want - bundles get built with no dependencies. However, I obviously can't leave the scenes this way (otherwise what's the point of prefabs) and I can't go and manually unpack everything before the build.

    I've found the IProcessSceneWithReport interface, which seems ideally suited for the task. However, when the OnProcessScene method is called, all prefab instances in the scene are ALREADY unpacked! GetPrefabInstanceStatus returns NotAPrefab for all objects, and UnpackPrefabInstance simply fails. The PostProcessScene attribute has the same problem.

    Is there any other way to do this?