2D Toolkit - 2D in Unity made simple [RELEASED]

Discussion in 'Assets and Asset Store' started by unikronsoftware, Jun 16, 2011.

  1. edwon

    edwon

    Member

    Joined:
    Apr 24, 2011
    Messages:
    40
    Mesh Collider Drawing Tool would be absolutely excellent. I've found that having irregular shapes for collisions would be very very helpful.
     
  2. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi,

    In your case, it looks like its filtering incorrectly and/or the texture is being compressed. Can you verify that the atlas texture isn't compressed (this is left on by default), and try ticking "Pixel Perfect Point Sampled" and Commit after that.

    Are you downscaling the images in any way? The default behaviour is to add 2 pixels of padding (when Pixel Perfect isn't ticked, which should let you downscale to 50% with no issues in the border at all, and we do that in our games).

    We have changed the behaviour in the latest version so there is a Compression option in the SpriteCollection itself, so it will be more obvious whats happening, and the Filtering settings are set up automatically based on the Pixel Perfect tickbox too.

    unikron

     
  3. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    Hi

    I am having trouble getting the Auto Fill for a Sprite Animation working. I have a Sprite Collection with Texture Refs named: Walk00 - Walk35. I select one of them for the first frame and click Auto Fill and nothing happens. Any thoughts on what I could be doing wrong?
     
  4. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    What you're describing seems correct. I take it you have committed your sprite collection, and that your names are correct in the list box. Please make sure that the case is correct and consistent in there too, as there is a bug with this in the current version. Also one more thing to try - create a new sprite collection, populate it and test that. Finally, What version of 2d toolkit are you running, and on what platform?
     
  5. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    I was missing Walk00, so I added that back in and I renamed them to all lowercase (walk00 - walk35). I'm not sure which of them fixed it, but it's working now.

    Thanks for the quick response!

    Oh, and I have a request for future versions. Please add a PauseAnimation() and ResumeAnimation() to the API.
     
    Last edited: Aug 19, 2011
  6. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    I'm having an issue accessing the API. Here's what I'm doing:
    1) Create an Animated Sprite in the Hierarchy and set the variables in the menu. This works correctly, I can run the program and it works as expected.

    2) Create a new script called Employee and within the Start function have the following line:

    gameObject.GetComponent(tk2dAnimatedSprite).Play("Walk");

    3) Add the Employee script to the Animated Sprite and run the game.

    This gives me the following error:
    Assets/Employee.js(13,46): BCE0005: Unknown identifier: 'tk2dAnimatedSprite'.

    Thoughts?
     
  7. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    I will get this added to the next beta. By pause and resume I take it you simply want it to stop on the frame it's at, and then continue from where it left off?

    Unikron
     
  8. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    create a Plugins directory within TK2droot and move the tk2d directory into it. This should fix the problem. We will do this by default on the next release.
     
  9. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    Yes, that's exactly what I meant.

    Moving the files to a Plugins directory worked, but I also had to leave all the editor files outside of the plugins directory for the Inspector menus to continue working properly.

    Thanks for your help!
     
  10. oliverdb

    oliverdb

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    165
    Well here is my Settings.. The funny thing is the target Ortho of 1, where my cam is 10. But its the only way I could make it work. The Atlas is set as an GUI.

    [​IMG]
     
  11. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Setting cam ortho = 10 implies that its drawing into the wrong camera. In this case, it would really help if you could send me a package of the scene to investigate, as you seem to have it set up correctly. You can clear out the RGB channels of your textures if they are confidential. This could certainly save a lot of back and forth on the forums.

    Let me know if this will work for you.

    unikron

     
  12. Cico

    Cico

    New Member

    Joined:
    Aug 21, 2011
    Messages:
    11
    It looks awesome. Really amazing tool,good job
     
  13. oliverdb

    oliverdb

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    165
    Yes it will work, but where to send it?
     
  14. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Check your PM
     
  15. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Version 1.10 has been submitted to the Asset Store!
    Those with beta access can grab it directly from the beta site if you prefer.

    We have also launched a website for the product. We intend on updating it with the new features and bonus content, but for now it is mainly a live list of FAQs. The support form also does come straight to us, so if you need to contact us, you may use the website over the Unity forums if you do not wish to register here.

    Version 1.10 is our biggest release to date. It has a major new feature, the ability to create multiple atlases directly from one Sprite Collection. This really speeds up building animated sprites when you have LOADS of frames. It is also brilliant for when you're developing your game, and don't want to care about where things end up! This feature involved getting a new texture packer, which tends to pack textures much much better than the built in Unity one, so you might get gains by simply switching over to the new format. We have also added across the board editor performance and memory improvements to help mainly with larger projects, but to those who have small projects, it is still a noticable improvement.

    We hope you enjoy this version, and as usual, feel free to post any support requests / suggestions / issues either here, or use the mailer on the website.

    unikron
     
  16. sibhod

    sibhod

    New Member

    Joined:
    Apr 13, 2009
    Messages:
    20
    Apologies if this a dumb question, but coming from flash development I'm new to Unity and C#:

    In my game pre-viz I've been animating some background elements like trees, flowers, and hills to bob or sway. Now that I'm finally building out the scene in Unity I'm confused about how to accomplish this. I was assuming instead of tons of animated sprites I could accomplish the effect by just modifying the meshes of the actual sprites. When I affect the mesh with a modifier like Mega-fiers it will initially work in the scene, but on first run the mesh resets and stays that way.

    Am I doing something wrong, or is this even a feasible way to modify sprites beyond scaling? Would it be less expensive to just create several animated sprites?

    Cheers!
     
  17. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi,

    This Is a very good question, and I will attempt to answer it as well as I can. There are multiple ways of achieving what you are after.

    Firstly, if you can spare the texture space, creating an animated sprite will probably be the easiest option. This fits in perfectly with how 2d toolkit works, and won't need any additional code.

    If your target is iPhone 3GS and above, you can use a shader to perform the deformation. This will by far be the most optimal solution. You can use the vertex color or alpha to seed the deformation, and you can have a large number of meshes moving simultaneously. The static sprite batches will also work in this case, and here, drawing this geometry will only be marginally more expensive than drawing the static one.

    If you need to target other platforms which don't have vertex shader support, your best bet will be to write a custom sprite class inheriting from tk2dSprite, much like how the tk2dAnimatedSprite works, but here you will be doing something similar to the vertex shader but in c#. In terms of efficiency, this won't be anywhere near as efficient, but will work with minimal changes. Since you already have megafiers, all you will need to do is copy the deformation code to do the same thing here.

    Hope this helps, and if you need any further pointers, feel free to send a PM.

    Cheers,
    Unikron

     
  18. netics

    netics

    Member

    Joined:
    Aug 23, 2011
    Messages:
    48
    question.

    in tk2dTextMesh.cs, line 267~277,

    is it right that using variable maxWidth instead of width?
     
  19. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Yes that is correct. In the case of single line text, it should be no different. However there was a bug where the centring for multiline text was only being performed on the length of the last line and not the full length of the entire mesh. This is what those changes fix.

    Are you having any problem with it?
     
  20. netics

    netics

    Member

    Joined:
    Aug 23, 2011
    Messages:
    48
    in new version, is it fixed?

    my version is still using 'width' there. (downloaded yesterday)
     
  21. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    The latest version which was submitted yesterday 1.10a definitely has this fix. Our first upload attempt went horribly wrong as a bunch of files simply got deleted. You could try redownloading from asset store and reimporting...

    Let me know how it goes.
    unikron
     
  22. netics

    netics

    Member

    Joined:
    Aug 23, 2011
    Messages:
    48
    tried again and updated successfully.

    but asset store displayed wrong message. it said that "asset is up-to-date. do you still want to download?"
     
  23. Uichi

    Uichi

    New Member

    Joined:
    Aug 24, 2011
    Messages:
    2
    I use Japanese characters in TextMesh.
    I converted the fonts hiragana in BMFont tools
    An error occurs when a set of Hiragana characters in TextMesh.
    Why do not other than English supported?

    tk2dTextMesh.cs line 256
    IndexOutOfRangeException: Array index is out of range.
     
  24. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    It should be supported; support for > 256, but not sparse character sets was added at one point during development. That means you can have a continuous Unicode range working, but not mix ASCII Hiragana, for instance.

    Can you send a PM with your BMFont (maybe a link on dropbox) and I will get it looked at for you.

    unikron

     
  25. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    I have just checked, and it turns out the support for > 256 was never commited to the repository. We still do have the code, so if you want it, we can certainly send it over to you.

    In addition, it would be useful to know how important a sparse character set would be to you, and other users; we could add it as an option if necessary. Our main priority is speed, but we could have a second slightly slower version of the TextMesh class which uses a sparse character set.

     
  26. ArtX

    ArtX

    Member

    Joined:
    Jul 13, 2011
    Messages:
    16
    Hi!
    I'm using function to check pixel alpha of sprite. But in new version of toolkit there are rotations flipping of sprite in sprite collections(SC). Please help how to disable rotation flipping sprites in SC. Is it possible to add it to setting of SC?
     
  27. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    It certainly is possible, though it won't get as good packing when it doesn't flip. Is there any particular reason you are reading alpha? There might be something else we can do to help which won't require turning off rotations.
    Unikron
     
  28. ArtX

    ArtX

    Member

    Joined:
    Jul 13, 2011
    Messages:
    16
    I'm reading alpha in my game to detect if such zone(not rectangle) selected. Also use it in buttons for more correct selection. It will be helpful to add data about rotation flipping in sprite collection data
     
  29. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Ok, I will add info about rotation in there. The texture is only rotated one way so it should be easy to remap. Would that be sufficient?
     
  30. ArtX

    ArtX

    Member

    Joined:
    Jul 13, 2011
    Messages:
    16
    Thanks, it's all what i need.
     
  31. Uichi

    Uichi

    New Member

    Joined:
    Aug 24, 2011
    Messages:
    2
    Thanks for answers.
    I saw the source.
    I understand that there must have contiguous character code than 256 characters.
    I wanted to know the specification of the TextMesh.
    No problem so far by not correspond.

    But eventually, even if consecutive character codes, and even less efficient,
    We need a TextMesh work as expected.

    Unity unfortunately does not currently support dynamic fonts. (iOS, Android)
    When multilingual, if more restrictions such as Japanese characters can only use a single texture is a problem.


     
  32. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi Uichi,

    Please send us a support email from the website: http://www.unikronsoftware.com/2dtoolkit/. We can continue this discussion by email, and see what we can do to help you. The 256 character limitation isn't rigid, you can increase the limit and it will work correctly. It currently does artificially prune the list to 256, and the memory overhead of larger indices is quite minimal.

    Also, if there is a contiguous block, we had an offset in there so it was still super fast at indexing (no Maps, etc). I do have an idea for efficient indexing of sparse characters, but we should really discuss your requirements further first.

    unikron

     
    Last edited: Aug 26, 2011
  33. rocket5tim

    rocket5tim

    New Member

    Joined:
    May 19, 2009
    Messages:
    202
    Hi, does 2D Toolkit support fonts made with Glyph Designer (http://glyphdesigner.71squared.com/)? Their website says "Export your Glyph Designer projects to the widely supported Angelcode format, allowing you to design text for any platform." (Anglecode = BMFont) but before I buy GD I'd like to find out if it works ok, if all of the features are supported, etc. Anyone tried it?
     
  34. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi Tim,

    I would say if you would like to use Glyph Designer, just go ahead and get it. If it doesn't work for some reason, simply send me the font which doesn't work and I'll get that sorted out for you.

    Hope that helps
    Unikron
     
  35. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi Tim,

    I can now confirm that 2D Toolkit works correctly with Glyph Designer, and we have updated the website to reflect this.

    From the FAQ page on the website:

    How should I export my data from Glyph Designer?
    2D Toolkit correctly supports all the export options from Glyph Designer. Due to the "Sparrow" config producing slightly different outputs, it is recommended to use the Cocos2D or EZGUI export options.

    unikron
     
  36. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    A new version has been uploaded to the beta site.

    The changelog for this version is:
    List of sprites is always sorted, regardless of order in SpriteCollection
    Fixed occasional error with uninitialised prefab in Editor
    Info field in SpriteCollectionData to mark flipped entry
    Default values property in SpriteCollection, all further insertions will use these defaults
    Few more bug fixes
    NOTE:One more feature remains incomplete, to alert the user when leaving sprite collection editor without committing

    The final version should be ready for submitting to the Asset Store next week.

    unikron
     
  37. rocket5tim

    rocket5tim

    New Member

    Joined:
    May 19, 2009
    Messages:
    202
    Thanks for the update on Glyph Designer and the beta! Looking forward to getting the new release version.
     
  38. aigam

    aigam

    Member

    Joined:
    Dec 31, 2005
    Messages:
    162
    The glyph support rocks! Thks!
     
  39. arcandio

    arcandio

    New Member

    Joined:
    Aug 30, 2009
    Messages:
    69
    I don't use C# very much, and thus I know nothing of these delegates you mention in the pdf. How would I implement a function call when an animated sprite is done playing its animation, for example to destroy that sprite?

    also, my 2dtoolkit game is looking RAD. THANK YOU. AGAIN.
     
  40. organicoder

    organicoder

    New Member

    Joined:
    Jul 20, 2011
    Messages:
    10
    Why does it say that it 2DToolkit cost $55, but in the asset store is says $68.75? I prefer to pay the $55 if possible :)
     
  41. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Unfortunately, we aren't in control with what Unity do to the prices after we submit it... It looks like they are adding 25% European VAT to the price :(

    unikron
     
  42. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi,

    How are you accessing the functions from JavaScript? Any further info here will certainly help me get you some example code.

    In theory, all you need to do is declare a function with the correct signature in your JS code, and simply pass that as a value to animationEventDelegate. For example, if your function is declared as such:

    Code (csharp):
    1. function DestroyWhenTriggerered(sprite : tk2dAnimatedSprite, clipId)
    2. {
    3.     // destroy self
    4. }
    5.  
    6. var animatedSprite : tk2dAnimatedSprite = gameObject.GetComponent(tk2dAnimatedSprite);
    7.  
    8. function RegisterDelegate()
    9. {
    10.     animatedSprite.animationCompleteDelegate = DestroyWhenTriggered;
    11. }
    unikron
     
  43. oliverdb

    oliverdb

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    165
    Hey Unicron

    Is there any way to play a frame at the time. I want to decide when the next frame is played.
     
  44. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi,

    There isn't. You could however modify tk2dAnimatedSprite (or create a copy of it) to do it, and it would be really simple to do it. I can't justify having this as a supported feature, but if you get stuck, simply send me a PM and I'll try to help out.

    unikron
     
  45. ShadowGhost

    ShadowGhost

    New Member

    Joined:
    Sep 2, 2011
    Messages:
    14
    Hi guys,

    This really looks good, and I'm seriously thinking about trying it, but could you fill me in on one thing I'm confused about. Does the TK come with any built in sprites that are usable royalty free?

    Thanks
     
  46. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    That is a good question.

    Most of the gfx used in the demos are drawn by us (using 100% legal software!) or generated with free tools. This means you can use them for any purpose you see fit when you buy the toolkit.

    Some of the other sprites included are royalty free ones from the internet, so I suppose you can use them, but please do check the licenses for those images. We always credit when a sprite is sourced from elsewhere, so there is a text file in some of the directories saying where the sprites came from.

    Having said that though, there aren't THAT many sprites in here, so if you are looking solely for a library of sprites to buy, this is probably not your best bet.

    unikron
     
  47. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    I have a question about the tk2d shaders. I need to be able to adjust the alpha levels on my sprites and since the shaders don't have a color property I can't access it. I manually added

    _Color ("Main Color", Color) = (.5,.5,.5,1)

    to the properties within the shader. So I can now use the following command without it kicking an error:

    theObject.GetComponent(Renderer).material.color.a = .5;

    The problem is that it doesn't actually change the alpha level of the sprite. Do you have any idea how to adjust the shader so that this command would actually have an effect?

    -Jay
     
  48. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,234
    Hi,

    Just out of curiosity, is there any reason you aren't using the .color property of the tk2dSprite? That will let you adjust color and alpha of individual sprites and not break batching. You can check this out in the interface, and the values are fully accessible from script.

    unikron
     
  49. gamefools

    gamefools

    New Member

    Joined:
    Apr 9, 2011
    Messages:
    35
    No, I didn't realize I could do this. How would I set this on an AnimatedSprite via code?

    -Jay
     
    Last edited: Sep 2, 2011
  50. Seokho

    Seokho

    New Member

    Joined:
    Aug 31, 2011
    Messages:
    23
    Hello Unikron.

    I have questions for you
    1.
    sprite collection's atlas which was built by 2D Toolkit has "Texture Type" - Texture and "Texture Fomat" - Compressed.
    But 2D game is not good enough "Compressed Texture Format". looks like a bad sprite.
    I should fix this to "RGBA32 bit". Then Texture's capacity (?) is very big. (1024 X 1024 - 4.0MB ~ 5.3MB)
    Is it right to make a atlas texture with RGBA 32 bit formatting?
    What is a best practice this feature?

    2. Atlas Texture should be true at "Generate Mip Maps" option?
    2D game doesn't need "Mip Map" option.
    But 2D toolkit's document recommend that option for resolution (iPhone 4G -> iPhone 3GS pixel perfect)
    What should I do? enable this option or not?

    3. When I make sprite's atlas texture, shouldn't have fix atlas texture size?
    EZ GUI SM2 ex2D support this feature.
    But 2D ToolKit does not and u said just using "Dice" option.

    Sincerly.
     
    Last edited: Sep 2, 2011