Hello Guest

Author Topic: Some doubts with regards to 2D Toolkit and AssetBundles  (Read 3898 times)

davidps

  • Newbie
  • *
  • Posts: 1
    • View Profile
Some doubts with regards to 2D Toolkit and AssetBundles
« on: June 24, 2014, 08:57:58 am »
I have started using 2D Toolkit recently for a mobile game for iOS and Android. While everything seems to be working fine with regards to platform-specific sprite collections (which we are going to use extensively due to our need to support a vast number of resolutions), I am now thinking about not including every platform's asset variant in the final application and download only the appropriate ones via AssetBundles. Searching on the forums for related topics, the canonical way to do this seems to be to create AssetBundles that contain only sprite collections of a given platform (1x, 2x, 4x) and load the appropriate one, depending on the platform, in code. Which leads me to the following question: if right now I am able to design scenes directly in the editor by adding tk2dSprite instances to it and setting their collection and sprite properties directly in the Inspector panel, is there a way to do that (i.e., design our scenes visually, possibly using the asset variants of a 'reference' platform just like we do with the usual 2D Toolkit workflow with no AssetBundles) when the collection and sprite is set in code from a loaded AssetBundle? As far as I understand, if I were to compose a scene by directly setting collections and sprites from the editor the referenced resources would always be included in the final application which kind of defeats the point of having AssetBundles in the first place.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Some doubts with regards to 2D Toolkit and AssetBundles
« Reply #1 on: June 24, 2014, 04:30:26 pm »
The best place to inject something like this is in the tk2d Sprite Collection platform system. This line in tk2dSpriteCollectionData.cs loads a sprite collection given a platform name, etc.
platformSpecificData = tk2dSystem.LoadResourceByGUID<tk2dSpriteCollectionData>(guid);

If you can inject the appropriate asset bundle sourced sprite collection in there, it will just work like a charm. Then you can worry about how you create the data.... You can integrate quite tightly with tk2d, with appropriate modifications of course, to get it to generate the data for you.