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

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

  1. eriihine

    eriihine

    New Member

    Joined:
    Nov 27, 2011
    Messages:
    13
    Updated to 1.7.1 patch1 over the weekend, but I'm getting following errors after the import has been completed.

    With the new version I can no longer add sprites to my atlases. I'll always get the same errors.

    1.6.1 patch 1 is working normally for me.

    No other changes were done to the project.

    Is this a known problem to be fixed by 1.7.1 patch 2 ?


    Texture has out of range widht / height
    UnityEngine.Texture2D:.ctor(Int32, Int32)
    tk2dSpriteCollectionBuilder:processTexture(tk2dSpriteCollection, Boolean, Boolean, Texture2D, Int32, Int32, Int32, Int32, SpriteLut, Int32) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:356)
    tk2dSpriteCollectionBuilder:Rebuild(tk2dSpriteCollection) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:743)
    tk2dSpriteCollectionBuilder:RebuildOutOfDate(String[]) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:133)
    tk2dSpriteCollectionTextureWatcher:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionTextureWatcher.cs:24)
    UnityEditor.AssetPostprocessingInternal:postprocessAllAssets(String[], String[], String[], String[], String[])



    UnityException: Failed to create texture because of invalid parameters.
    UnityEngine.Texture2D..ctor (Int32 width, Int32 height)
    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/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:356)
    tk2dSpriteCollectionBuilder.Rebuild (.tk2dSpriteCollection gen) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:743)
    tk2dSpriteCollectionBuilder.RebuildOutOfDate (System.String[] changedPaths) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:133)
    tk2dSpriteCollectionTextureWatcher.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionTextureWatcher.cs:24)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)
    UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets)
  2. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Yes.
    This should've been fixed by patch2. You can also manually apply the patch as described a few posts above.

    That was an unfortunate typo, sorry about that.
  3. kaki

    kaki

    New Member

    Joined:
    May 7, 2012
    Messages:
    1
    I wanted to read the documentation on this product but both the official website and this thread links are bad... shame, i need a 2d toolkit that i can use soon... im not a fan of silent videos using text to explain things...
  4. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    The docs site was down temporarily due to a problem with my sync script. It should work fine now. The walkthrough in the docs are always kept relatively up to date, so its probably best to use that as reference rather than the quickly outdated videos. We keep adding tons of features, and its not practical to re-record videos every time.

    That said - more tutorials are coming soon to walk through all the new features which have gone in since 1.6/1.7 - embedded fonts, new sprite sheet import, tilemap editor, etc.
  5. chillypacman

    chillypacman

    Member

    Joined:
    Oct 1, 2011
    Messages:
    52
    Yes sprites are animating, I'm using the latest version of 2D Toolkit.

    I added an exception check there and let it fall through, it seems to fix itself after an initial exception is thrown.


    I have another question now, is it possible to grab the UV data of an animated sprite and apply it to something else? The reason I ask is 2D toolkit 2D scales the size of sprites based on the size of each individual sprite in the sprite sheet, so when I'm mkaing an iPhone port of a game if I make all the sprites imported at half their normal size 2D Toolkit will halve the size of all instances of that sprite in the game world. I would like to take the UV data applied to that sprite and put it on a plane or a cube (or anything really) which won't get scaled by 2D toolkit.

    Sorry I hope I made sense with that comment? Basically if I change the import settings of a texture to be half its original size 2D toolkit will halve its size in the game world so suddenly a character is now half the size it should be on iOS but fullsize in PC.


    Just started having problem with some textures I wanted to add to a sprite collection, if I try to add this texture to a sprite collection: http://i.imgur.com/e5pyU.png (it looks white but it isn't)

    I get the following errors:


    Last edited: May 9, 2012
  6. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Are you running the latest version (1.70 patch2)?
  7. chillypacman

    chillypacman

    Member

    Joined:
    Oct 1, 2011
    Messages:
    52
    oh I'm using an older version as I haven't updated to Unity 3.5.1, I'll update it and get back to you :)
  8. gabidof

    gabidof

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    14
    Hi Unikron, i have a problem, when i put a new box collider in one sprite, the Z Position set me in -100000 automatically, and i can't move from that position, i don't which is the problem.

    Thanks.
  9. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    This implies your sprite isnt set up with colliders in the sprite collection editor. If you set it up in there, everything should just work fine.
  10. Sytto

    Sytto

    Member

    Joined:
    Jul 20, 2010
    Messages:
    27
    hi, i'm having some troubles adding colliders in the new sprite editor, when i set collider type to "polygon", the green collider box never appears, same with the rest of types of colliders, that box only appears if i check the "custom shape" box. what i'm doing wrong?


    edit: ok i didn't watch the "collider" tab down there :p i'm still getting used to the new editor
  11. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    It probably will get a bit of getting used to. There is a lot more functionality in there though. For example, you can draw polygon sprite shapes in addition to just polygon colliders hence the requirement for a "mode" tab.

    Glad you've got it figured out though :)
  12. NateJC

    NateJC

    Member

    Joined:
    Apr 10, 2012
    Messages:
    27
    I noticed that ex2d supports: "adding animation events directly in the timeline editor."
    Does 2dtk have a similar feature?
  13. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    You can attach animation events to frames in the animation editor. I'm not sure how it works in ex2d, but ours fires when the frame of animation is shown, which may or may not be ideal. The animation editor is due a revamp soon though, so if you have any requests feel free to let me know.
  14. helioxfilm

    helioxfilm

    Member

    Joined:
    Apr 23, 2008
    Messages:
    252
    Well, we have talked about it earlier, a kind of animation blending via crossfade could be useful, if feasible...
  15. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Hi,
    I did actually do some tests with this and the results are 50-50. It could work as a special case with a lot of constraints, but not as a generic solution. Also, don't forget that 2 textures would have to be sampled for each of these further reducing performance, this overhead would be constant for the whole atlas, unless you're willing to trade draw calls for this. I think I may create an "unsupported" sample of how to do this, but I doubt it could be part of the main distribution.
  16. TTkJonas

    TTkJonas

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    28
    Hello unikron,

    is there a video somewhere that shows the function of the tilemap editor? Or more images as shown in the documentation? That would be great :)
  17. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Not yet, the tilemap editor is still under active development and more features and improvements are going in constantly so any videos are going to be outdated very soon. More docs coming soon too! If you need any help with it in the meantime feel free to post here, our forum, or email support at unikronsoftware dot com.

    We don't have a demo scene yet, either, so that is coming soon too. Edit: we'll need a fair few scenes to demonstrate all the different features supported.
    Last edited: May 14, 2012
  18. TTkJonas

    TTkJonas

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    28
    Thanks for the quick answer!
    I think much about it, to buy the 2d toolkit. But what happens when version 2.0 appears? Will it be already in the near future and will the update cost money again? ;-)
  19. unikronsoftware

    unikronsoftware

    Member

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

    All future updates to 2D Toolkit will be free. There might be paid add-ons in the future, but that won't be an essential part of the core product. Hope that answers your question.

    I had this typed so long ago but must've forgot to click "Post" :)
  20. kevork

    kevork

    New Member

    Joined:
    Aug 28, 2011
    Messages:
    31
    @unikron, first, we've been using 2D Toolkit for months now, and it is great, so thanks! For my question, we are switching an existing product from Sprite Manager 2 to 2D Toolkit, however the existing product is currently using TruncateTop/Bottom/Left/Right. Is there an easy way to do this with 2D Toolkit? Thanks again.
  21. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Not in the official distribution, but there is an "unsupported" clipped sprite implementation that you can use here. Its in the private support area of our forum, you'll need to register your copy if you haven't already.
  22. kevork

    kevork

    New Member

    Joined:
    Aug 28, 2011
    Messages:
    31
    Worked great, thanks again.
  23. yotes

    yotes

    New Member

    Joined:
    Mar 18, 2012
    Messages:
    14
    Hi all, i am thinking in 2d toolkit to create a fun Gui hud in my gameplay.. I bealive this tool can help me.. but before i buy it, i need to know if there is any restriction with the 3d world, or it will work correctly if i use it just like a hud.

    Thanks! and the tool looks great, it's such a petty you dont have a trial version
  24. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Hi yotes,

    It works fine in 3d worlds. One of our demo places a sprite in a 3d scene and as far as Unity is concerned its just a 3d object, and just works. You constrain it in 2D, etc and use an ortho camera to make it "2D".

    I've had a few requests for a trial version, but the main problem is 2D Toolkit is distributed in full source, and I'd really like to keep it that way. The problem is its really hard to create a trial from a product which is distributed in source, and where one of the main values is the fact that you get full source. I've had a few ideas on how to do create something workable, but it will be a while before I get around to setting it up really.

    unikron

    Edit - Obviously if you're gonna display it in 3d, you'll need anisotropic filtering turned up and also a bit more padding as you're more likely to actually require the mipmaps then.
  25. yotes

    yotes

    New Member

    Joined:
    Mar 18, 2012
    Messages:
    14
    Ok, thanks, yes of course i know that the problem is the source code, and the extra work that it requires.

    One thing, I don't want to show my sprites in 3d, they will be on the front as a hud (I'm learning unity and 3d, so I`m a noob and I don't know the correct words -I harldy can write in english :p- ) the game inself will be 3d, but I just want 2d toolkit to make the gui, because there are many tools to do this, but i want something less restrictive, and more artistic.. I believe this is the tool to go.

    Thanks for your fast answer! I'll chek the video that you said!
  26. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Yeah thats fine too. That same demo i mentioned also has 2d elements in the same scene, using a second camera to overlay it. You're really free to do what you want / like, there aren't any restrictions in place with the 2D elements.
  27. TorontoJoe

    TorontoJoe

    New Member

    Joined:
    Mar 25, 2012
    Messages:
    32
    *edit* nevermind. :)
    Last edited: May 17, 2012
  28. khaosenygma

    khaosenygma

    New Member

    Joined:
    May 5, 2011
    Messages:
    27
    Has anyone ever had trouble resetting a tk2dAnimatedSprite after it has played? the only way I can see how is to have the last frame of the animation return to the original state. any advice?
  29. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
  30. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    We have a tutorial in the May Asset Store newsletter titled "Sprite Optimizations using 2D Toolkit". Its a walkthrough covering sprite dicing, custom sprite shapes and multiple materials, well worth a look if you haven't tried these features already.

    http://unity3d.com/unity/asset-store/in-depth/issue4
  31. mobilegamelabs

    mobilegamelabs

    New Member

    Joined:
    Apr 11, 2012
    Messages:
    25
    Hi,
    I like both the DemoFont and GradientFont in the package. However, I am using them in a 960 x 640 resolution so the texts become very much blurred. If you have time, could you please release a newer version (another material as well) so that which is suitable to use for very large text e.g. 100 units tall.

    Thanks very much for your time!
  32. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Hi!

    That font is from here - http://www.myfonts.com/fonts/tipos-pereira/londrina/
    You can use that to generate any size you'll need. If I generated one at 2x, it really depends on the size you'd like to view it at as well.

    Looks like their license has changed (the font used to be called Folk, and the license was different, its still free though). I've added the sources to credits.txt in the demo folder in the 2D Toolkit package.
  33. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
  34. fanxu1218

    fanxu1218

    New Member

    Joined:
    Apr 26, 2012
    Messages:
    2
    hello, I have a question,I don't konw how to use the button delgate and event,can you help me,write a example or a demo for me ,my email is fanxu1218@hotmail.com,thank you very much
  35. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    I've posted a reply to your PM, but here is a copy of the script in case it can be of use to anyone else.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class ButtonTestScript : MonoBehaviour {
    6.  
    7.     tk2dButton button;
    8.    
    9.     // Use this for initialization
    10.     void Start () {
    11.         button = GetComponent<tk2dButton>();
    12.         button.ButtonPressedEvent += ButtonPressed;
    13.         button.ButtonAutoFireEvent += ButtonAutoFire;
    14.         button.ButtonDownEvent += ButtonDown;
    15.         button.ButtonUpEvent += ButtonUp;
    16.     }
    17.    
    18.     void ButtonPressed(tk2dButton source)
    19.     {
    20.         Debug.Log("Pressed");
    21.     }
    22.    
    23.     void ButtonAutoFire(tk2dButton source)
    24.     {
    25.         Debug.Log("Autofire");
    26.     }
    27.    
    28.     void ButtonDown(tk2dButton source)
    29.     {
    30.         Debug.Log("Down");
    31.     }
    32.    
    33.     void ButtonUp(tk2dButton source)
    34.     {
    35.         Debug.Log("Up");
    36.     }
    37.    
    38.     // Update is called once per frame
    39.     void Update () {
    40.    
    41.     }
    42. }
    43.  
  36. arcandio

    arcandio

    New Member

    Joined:
    Aug 30, 2009
    Messages:
    69
    Hello again,
    In the process of updating and turning my old game into an android game, I came up with this error when trying to access Play on a tk2dAnimatedSprite from Unityscript.

    I've googled it a couple of times but the last time it came up was way back before you changed the architecture, so the old solution doesn't work anymore, as far as I can tell.
  37. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Have you tried the Setup for JavaScript menu item? That should just fix it.
  38. arcandio

    arcandio

    New Member

    Joined:
    Aug 30, 2009
    Messages:
    69
    worked like a charm. Just didn't know where to find that. Thanks!
  39. mobilegamelabs

    mobilegamelabs

    New Member

    Joined:
    Apr 11, 2012
    Messages:
    25
    Thanks very much!
    Could you give me some hints about how to use the downloaded files from that site in 2D Toolkit?
    Moreover, could you also release a high resolution version of "grad" texture used in the gradient font? Thanks!!!
    Last edited: May 28, 2012
  40. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
  41. sp00ks222

    sp00ks222

    New Member

    Joined:
    May 12, 2011
    Messages:
    37
    Question about using large image/dicing. I have a large 2d uneven terrain (mostly straight angled lines, but all different sizes and distances) that I would want to import into unity, and possibly get diced up with 2dtoolkit. My only problem would be with collision/colliders. I don't think I would want one huge collider for my entire terrain, as it would have many faces. What technique should I be using to get the best performance?
  42. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    Large mesh colliders arent an issue. Mesh collider performance balances out after you go beyond a certain number of box colliders forming the original mesh. In this case, having one MeshCollider could be a win. Having lots of mesh colliders would be a bad thing obviously, and performance will suffer, but having one large one should be fine. My suggestion is to try it first to see what performance is like before trying any of the more complex solutions.
  43. stuatk

    stuatk

    Member

    Joined:
    Nov 18, 2009
    Messages:
    48
    Hi,
    Just starting using 2dtoolkit - really enjoying so far (much nicer to use that SM2), quick question:

    Keeping track of a flipped sprite - am I missing something or should there be a .isFlipped property on the sprite? Or do we look at the scale property to obtain this? Or am I missing something?

    Basically I need to do this: if( mySprite.isFlipped == false ) mySprite.FlipX();

    of even better - maybe a mySprite.UnFlipX(); would be best :)

    Thanks!

    ( update: after flipping the scale does show -1 )
    Last edited: May 30, 2012
  44. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230

    The easiest way to detect flipped sprites is to look at the tk2dSprite.scale property. If .x < 0 then its flipped on the X axis, same applies to the Y axis. The scale is always local, so the signs of .x and .y directly tell you which axis if any is flipped.
  45. pestantium

    pestantium

    Member

    Joined:
    Jun 30, 2011
    Messages:
    25
  46. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    That is awesome stuff :) Glad 2D Toolkit helped in your project!

    p.s. I should create a showcase forum in our official forums to showcase projects created with 2D Toolkit.
  47. TTkJonas

    TTkJonas

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    28
    Hello unikron,
    is it possible to move the SpriteCollections and and/or Data Folders in unity, or will this crash the files?
  48. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,230
    It should be fine to move anything anywhere, but make sure you do it from within the Unity interface.
  49. TTkJonas

    TTkJonas

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    28
    Thanks!!! All works without Errors and I have nomore Folder chaos:)
  50. c-Row

    c-Row

    Member

    Joined:
    Nov 10, 2009
    Messages:
    738
    Hello,

    I am trying to do a raycast from one sprite against another (for testing purposes, sprite #2 is right above the ray origin sprite #1). The colliders have been set up, and as far as my Debug.DrawLine shows me, the raycast should hit the other sprite, but Unity seems to disagree. The Rigidbodys react to each other, though.
    Last edited: Jun 3, 2012