0

I have created an asset bundle which has sprites in folder hierarchy. What I want is that I get array of these sprites by using the parent folder name. Is this possible?

I can get single sprite using

 AssetBundle.LoadAsset<Sprite>("spriteName.png");

but I want array of sprites using the parent folder name. How can I do this?

Thank you

kashif789us
  • 474
  • 8
  • 23
  • try this http://docs.unity3d.com/ScriptReference/AssetBundle.LoadAssetWithSubAssets.html – LumbusterTick Feb 29 '16 at 07:37
  • I tried it but its something else. I think its used for extracting individual sprites form a sprite sheet using asset bundle. – kashif789us Feb 29 '16 at 07:40
  • Btw i dont understand when you say "asset bundle which has sprites in folder hierarchy", So you made sub folders and you want all sprites in a array , if thats the case why put them in folders in the first place ? – LumbusterTick Feb 29 '16 at 07:44
  • Use this http://docs.unity3d.com/ScriptReference/AssetBundle.LoadAllAssets.html then cast them into sprites. – LumbusterTick Feb 29 '16 at 07:45
  • Let me explain. For example, I have folders named "Monsters" and "Players". Monsters folder contains sprites of monsters and Players folder contains sprites of Players. I built an asset bundle with this hierarchy. So, what I want is that if I call Monsters folder and it returns me an array of sprites of monster and same for Players. – kashif789us Feb 29 '16 at 07:47
  • 1
    LoadAllAssets loads all the assets without the folder hierarchy. It will load all the sprites and folder hierarchy will be gone. For example, I have 100 sprites in my asset bundle. But I only want 10 sprites of monsters. Calling LoadAllAssets will load 100 sprites instead of 10. – kashif789us Feb 29 '16 at 07:48
  • so put them in different folders?? – Fattie Feb 29 '16 at 13:23
  • While building they are already put in different folders. But when asset bundle is made, this hierarchy vanishes and we can only reference the objects with their names. – kashif789us Feb 29 '16 at 13:25

0 Answers0