2D Toolkit Forum

2D Toolkit => Support => Topic started by: HankTurbo on September 19, 2014, 06:17:50 am

Title: Asset Bundle and tk2d
Post by: HankTurbo on September 19, 2014, 06:17:50 am
Hiya,

First of I would like to congratulate you on a fantastic product.

I have an issue with Asset Bundles and tk2d where I get the following error
    Inconsistent asset when sorting preload assets: '' fileID: 0

My asset bundle is extremely simple. I have one prefab which consist of
 - prefab (empty gameobject)
  -> sprite (tk2dSprite)

When I try and build a bundle (with dependencies) from this prefab (using the script from here http://docs.unity3d.com/Manual/abfaq.html), it throws the above error.

I tested building a bundle from just a tk2dSpriteCollectionData, and that works fine.
I tested building a bundle with just empty gameobjects, and that works fine.
But with a tk2dSprite attached to a gameobject it doesn't work.

Is this not possible?

Thanks in advance for any help given.
Title: Re: Asset Bundle and tk2d
Post by: unikronsoftware on September 19, 2014, 03:06:12 pm
Is that an error or a warning? I've not seen it before, but from what google says, its just a warning and not an error and that the assetbundle does get built correctly... If not, can you post a repro case of this, I'll be happy to take a look and see how this can be fixed. Prefab asset bundles work on my main project, but the setup could be different on yours.
Title: Re: Asset Bundle and tk2d
Post by: HankTurbo on September 21, 2014, 12:42:03 am
Thanks for the quick reply.

It's definitely an error, or at least that's what it's coming up as in the editor.

If I create a bundle with a single prefab with the above mentioned content, I get the error and the file size for the bundle is about 5.5 MB.
If I create a bundle with only the SpriteCollectionData object from the sprite in the prefab I don't get the error and file size for the bundle is about 10.5 MB.

So unfortunately I don't think it is creating the bundle correctly.

The only special thing I'm doing is that I've disabled "//if (!i.managedSpriteCollection)" in "BuildLookupIndex" for "tk2dSpriteGuiUtility", to be able to choose 1x and 2x SpriteCollections in the editor. So I can build seperate bundles for 1x and 2x.

I've attached a zip file of the actual prefab, but I don't know if that is enough? Do you want a whole project setup?
Title: Re: Asset Bundle and tk2d
Post by: unikronsoftware on September 21, 2014, 10:44:19 am
Are you using platform collections? That isn't going to work as it uses Resources.Load for the sprite collection data there...

Also I'll need a bit more than just the prefab, ideally a scenario / project where I can build the asset bundle in a way that it breaks. If you write a bit of code to load the asset bundle, and then print out all the objects in it, you might find out what is missing.
Title: Re: Asset Bundle and tk2d
Post by: HankTurbo on September 22, 2014, 03:44:22 am
Yes, I'm using platform collections. I have however made a system where I followed instructions from this forum entry http://2dtoolkit.com/forum/index.php?topic=1522.0
Would the scenario mentioned in this forum entry not work? If I build seperate bundles with 1x and 2x textures, and load them... would it not set the correct sprites using this approach? I am still at making bundles stage, so haven't loaded any of them in yet.

However waking up Monday morning with a fresh restart on my machine, I don't get the error anymore?? So it seems fixed(?), or that is at least the dream.

I will report back with more information if it start occuring again.
Title: Re: Asset Bundle and tk2d
Post by: unikronsoftware on September 22, 2014, 10:36:36 am
Next time it happens, try restarting into an empty scene, see if that fixes it. I think its something to do with the temporary link that exists when the object is being used, its a link to a transient object which may be what is throwing it off.
Title: Re: Asset Bundle and tk2d
Post by: HankTurbo on September 22, 2014, 10:41:13 am
Thanks for that, I'll keep that in mind next time it happens.

Would my approach to platform bundles work, or should I find another way to do it?
Title: Re: Asset Bundle and tk2d
Post by: unikronsoftware on September 22, 2014, 10:41:54 am
I think it will work, but I can't say for certain as I haven't tested it. You do have the source code though... :)
Title: Re: Asset Bundle and tk2d
Post by: HankTurbo on September 22, 2014, 11:09:14 am
Cheers, I'll give it a crack... just don't like modifying external libraries too much in case I need to update it for some reason (creates a general havoc).

Thanks for quick and helpful replies!