Hello Guest

Author Topic: Importing a Font into a Sprite Collection -- IndexOutOfRangeException  (Read 6332 times)

Bona

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Hi Unikron, thank you for providing these nice tools  ;D

I'm still learning the workflow and got stuck in "Importing a Font into a Sprite Collection"

My version is  1.7 final+patch 2 with Unity 3.5.1f2, after step 6 of the above walkthrough, I got these errors :

IndexOutOfRangeException: Array index is out of range.
tk2dSpriteCollectionBuilder.ProcessTexture (.tk2dSpriteCollection settings, Boolean additive, Boolean stretchPad, UnityEngine.Texture2D srcTex, Int32 sx, Int32 sy, Int32 tw, Int32 th, .SpriteLut& spriteLut, Int32 padAmount) (at Assets/TK2DROOT/tk2d/Editor/Sprites/tk2dSpriteCollectionBuilder.cs:309)
tk2dSpriteCollectionBuilder.Rebuild (.tk2dSpriteCollection gen) (at Assets/TK2DROOT/tk2d/Editor/Sprites/tk2dSpriteCollectionBuilder.cs:781)
tk2dSpriteCollectionEditorPopup.DrawToolbar () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:410)
tk2dSpriteCollectionEditorPopup.OnGUI () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:670)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

Have tried using the same .fnt for tk2d TextMesh without any problem, the font is from GlyphDesigner using Cocos2d Text format, also tried other formats and different char sizes and still couldn't pass that error.

Attached pls find 2 files for your testing use. Please help.

edit: attachments removed
« Last Edit: May 11, 2012, 08:57:50 am by Bona »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
This is a bug in the current version. It only happens when you create a sprite collection with no sprites (and just a font). An easy fix for now is to drag in a really small sprite into the collection, and then add the font.

It'll be fixed in the next release.

Edit: Drop me a PM/email if you'd like a copy and I'll send it your way. It may be a few days to a week before it gets packaged up and released.
« Last Edit: May 10, 2012, 03:13:34 pm by unikron »

Bona

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Thank you Unikron, that fixed it, SpriteCollection_Data folder of those fonts generated without problem.

Other than TextMesh, can I use those character sprites as "Tk 2d Sprite", too?

When I use the sprite collection the dropdown shows only the small sprite that I added to fix the bug, couldn't access to font sprites in the same collection from inspector. Don't know if it's designed to work this way, it would be nice if the font sprites can be used individually, too.

I'll wait for the next update, please take your time, your tools are very nice and I'm enjoy using it. ;)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
The font sprites aren't displayed in the sprite list, intentionally, as they don't exist as sprites. The reason is in a lot of cases you want to mix sprites & fonts in the same collection, and say you have 512 glyphs, that will seriously clutter up the selection dialog. I'll think of a way to make it optional at some point.

Bona

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Thank you for clarifying, back to explore the script ref now  ;D