Hello Guest

Author Topic: Create Sprite Collection from code  (Read 3805 times)

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Create Sprite Collection from code
« on: October 16, 2014, 09:19:53 pm »
Hi,
Is it possible to create the sprite collections purely from the code in the editor?

 I was poking around the sources and found the tk2dSpriteCollectionEditor and tk2dSpriteCollectionBuilder which could possibly create the sprite collection prefab. Then I think I would need to obtain the tk2dSpriteCollectionData somehow and add the sprite definitions there. Should I jut create new tk2dSpriteDefinition array and associate it to the "spriteDefinitions" field in the tk2dSpriteCollectionData ? Then after everything is done, I would call the tk2dSpriteCollectionBuilder.Rebuild() for committing the changes. Is this right? Or is there any other workflow?

Thank You

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Create Sprite Collection from code
« Reply #1 on: October 17, 2014, 12:29:19 am »
If you don't want to edit them, you can create a sprite collection data object using the runtime sprite collection method, then save the resultant prefab and materials. If you want to edit them, create a sprite collection prefab, then populate spriteDefinitions, and Rebuild.

There was another workflow in 2.4 beta 3 (http://2dtoolkit.com/forum/index.php/topic,3746.0.html). Look for data driven collections, we basically wrapped all of that into some nice scripting system. This is unsupported and doesnt support all features, but is totally worth looking into if you want to build a pipeline using this.

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Create Sprite Collection from code
« Reply #2 on: October 17, 2014, 07:15:12 am »
The link looks interesting (I was sure I have seen it somewhere but couldn't find it:) ). As it is unsupported (data-driven), where could I found the code? Should I extract the beta package and extract the files from there? Or is it somewhere on the github as you mentioned in the release notes?

Thank You

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Create Sprite Collection from code
« Reply #3 on: October 18, 2014, 08:55:52 am »
Just import the beta package, and only import the data driven collections code. I never got around to putting it on github as I haven't had enough time and there simply hasnt been enough demand for it.