unity3d - Is there a way to build asset bundle that exclude texture2d from an image? -


in unity 4.x, can archive because can select resource type directly sprite variable before putting bundle via buildassetbundle. however, in unity 5.x, need put name in editor can cannot choose resource type sprite in editor. when make bundle, bundle have both texture2d , sprite want sprite save memory , disk space. bundle exclude texture2d if create bundle prefab not image want raw image. should do?

as clarification future readers, i'm taking account your other question, , reason want exclude original texture because use atlas sprite packer generates.

short answer: don't add textures in bundle , let taken care of in shadows. each bundle, sprite or atlas needed referenced object needs it, included.

long, insightful answer: first, let's compare 2 assetbundle buidling pipelines:

sprites generated texture's import settings, , don't have assetimporter of own. texture atlases created sprite packer cached in \library\atlascache, don't have assetimporters either. means individual sprites , packed atlases can included in bundle when dependencies of included asset. as said working on it.

if add texture pack, sprites created added (this completeassets behaviour), of course add texture too. if sprite added, texture uses added (collectdependencies behaviour), regardless of if it's texture file in project or sprite packer atlas.

the bottom line don't want add texture. @ all. never. original textures editor work only. instead, need add bundle else references sprites, not texture itself.

the hackiest way using prefab script this:

public class spritereferences : unityengine.monobehaviour {      public unityengine.sprite[] sprites; } 

but chances among things want add bundle (prefabs, scenes, scriptableobjects) sprites need referenced, added, , in turn needed atlas added too. , done without adding original texture.

beware: if single object in asset bundle references sprite, whole atlas added. keep packing tags organized, should correspond bundles make.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -