Search Unity

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

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

  1. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    Hey just bought this and I already love it. One question though I started making the sprites into prefabs and when i modify the prefabs sprite script (like the color or size), I get lots of missing mesh errors. Is there a different place I should be editing these values?
     
  2. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    Also is there a way to use the same image for multiple prefabs using different pivot points?
     
  3. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Hello, 2Dtoolkit looks like the most intuitive and lightweight 2D solution around.
    (It's really hard to decide which 2D solution to chose, so many good ones)

    I like the way sprites are handled (static batching, dicing, pixel perfect auto management, sprite collection mini database, etc). Great work from you guys.

    In order for it to be perfectly viable for UIs, I'd like to know if these features are about to be released soon (if released at all) :
    - Scrollviews (sprite view cropping, for scrolling text)
    - Ability in a sprite animation to adjust any sprite frame duration (ex in explosion : explosion5 staying 10 frames, while all other stay 2 frames)
    - Therefore, ability to decide at what frame the FrameEvent is triggered

    That's all I can think about for vital stuff, really, which proves how complete the solution is.
    (and no DLL is very nice indeed)
     
    Last edited: Dec 23, 2011
  4. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    Could someone explain the "tigger" on the frame. What function gets called? How can i get function to be called once an animation finishes?
     
  5. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    230
    For those who were wondering, 2D Toolkit 1.51 (current version on the store) appears to be working fine with the Unity 3.5 developer preview. I haven't tried anything fancy using my own projects yet, but I was able to open all of the TK2D demo's and export them using the Flash player without any issues.
     
  6. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This is a known problem - it has been fixed for the next release. A (somewhat annoying) workaround is to drag your prefab into the scene, modify it, then click on apply. You can then delete it from the scene. Sorry for the inconvenience.
     
  7. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Yes. Simply add the same image multiple times to the sprite collection, changing the names of the duplicates accordingly. You will then be able to set different anchor points on them, and indeed different colliders too if you need that. They will only appear once in the atlas.
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Scrollviews and other GUI niceties will be in the version following the next - the next one will be a 3.5 update, have some bugfixes, tile map editor and perhaps a few more features if they are ready by then.

    We are also revamping the Animation editors - this may or may not make it into the next release - its come a long way but it's still not ready for release yet... We have 2 animation projects prograessing in parallel - one tidy up and another full revamp - the smaller one may make it into the next release - but I can not promise that at this point.

    You can set frame events now, it will simply call the delegate with the parameter of your chosing - you can then plumb it into different parts of your system.

    Cheers,
    Unikron
     
  9. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Thank you for your reply, that's good news.
     
  10. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    can someone explain the "FrameEvent" callback and give an example please.
     
  11. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Loving this tool and what I hear about it so far. Specially the "premultiply" function.
    However, I would like to ask one think:
    I had the chance to see this tool in action, but.. there was no atlas editor.. Only an automatic atlas creation tool. Will there be an atlas editor, just like ex2d or EasyMotion2d toolkits ?

    Waiting for a reply,
    thank you
     
  12. CoatlGames

    CoatlGames

    Joined:
    Apr 25, 2008
    Posts:
    773
    i just want to say that 2dtoolkit is beyond awesome!

    thanks for making this
     
  13. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    While this work with Flash export, it seems like the number of DrawCall has become 1 draw call per 1 Sprite/TextMesh object.
     
  14. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It looks like both static and dynamic batching aren't implemented yet on the Flash export plugin - both those options are greyed out. Seeing that it is implemented in every single one of their other platforms, including iOS and Android, I would expect this to be implemented at some point in the future, unless there are technical reasons not to support it.

    You can still use our Static Sprite batcher now for your static sprites backgrounds - those will reduce down to one draw call.

    I will get in touch with Unity Support after Christmas to see when these features will be implemented.
     
  15. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Glad you like it!
     
  16. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The FrameEvent (animationEventDelegate) is a method to get feedback to your script when a certain frame of animation is displayed. You can associate a string, float and int value to a particular frame of animation and you can use this to perform certain actions (eg. playing a sound when a foot hits the ground, etc).

    There is an example of this in "5 - animation", the particular example you should look at is "Message". Check out the source code for a real quick example of how to register a trigger for this delegate. The event is used to pop up a message when frame 3 is hit.
     
  17. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    There are currently no plans for an atlas editor, but we are planning import functions for various other atlas formats, eg. TexturePacker. The reason for that is a lot of our features (for example the sprite dicing, and auto sprite rebuild and atlas repack) is inherently incompatible, or totally impractical with manual atlas placement. It is also totally incompatible with some of the advanced features we are planning in the future.

    Is there any particular reason you need an atlas editor? We may consider it for a future update if there is enough demand, but this is the first request for one, as far as I am aware.
     
  18. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    Thank you for your answer, unikron. I'll try static sprite batcher and see if the result is better :)

    Also, it would be nice if you could add how to sort the object's draworder in the documentation. Currently, I guess that you have to adjust the object's z value just like normal 3d object right?

    EDITED : Just tried static sprite batcher and it was not what I was looking for. I'm working with moving sprites, so this won't do, unfortunately. I guess I have to try other genre for now then.
     
    Last edited: Dec 25, 2011
  19. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Thank you for replying my message.
    I've had the chance to play with all three 2D engines. EX2D, 2D Toolkit, and the new EasyMotion2D. This will be quite like a compairison, but I do not think compairing the best is a bad thing :)

    I can say, the "automatic placement of the atlases" one of the few drawbacks of this tool for me. Why ?
    1. Reuse of different parts: When you have the complete control over atlas placement, you can also create different sprites by using the different parts of the same image. Example: A house image could be a sprite by itself, but... one could also "draw a square" to the windows and record it as a seperate sprite to use. This could be a great feature in 2D Toolkit.. This feature is one of the best features I like in EasyMotion2D asset pack..

    2. Big texture placement: For some reason, the automatic placement can not handle textures that is exactly 2048 pixels long (is there a padding setting somewhere that I missed?). I've set the max texture size to 2048, but.... the error message simply says there is not enough space. If there was a manual placement system, I would simply place it manually by hand. in those cases..

    3. An additional feature implementation: Sometimes we need a LONG ground element, which is longer than 2048 pixels, but probobly only 100 pixels tall ! In those cases, a manual placement could give the control of creating one LONG sprite from many 2048px wide images. Surely it can be one single atlas, since a 2048*2048 atlas can take 20 of the 2048*100 of different ground elements, which could make a one single unibody piece of ground !

    Other than these, I also find the "adding and removing the elements" more easy when it is made visually. Surely, the support of list format is a great thing, but... right now the list is very hard to use since its impossible to re-order things. When I want to replace a used element in the list, this situation makes it almost impossible..

    Also I believe dicing could be possible, since you can do that in EasyMotion2D example again, with an easy-to-use visual interface..


    This looks like I am advertising the other tools.... But no. I like 2D Toolkit the most, since it WORKS as it should. The other tools I've tried were all either filled with bugs or too complex for the easiest actions ! 2D Toolkit does not only smell good programming, but also smells a good designer point of view ! Finding the -easy to use- "premultiplied alpha" function was a shock for me as a designer, who has to deal with manual work of those things !

    But as I mentioned, I believe a more visual interface could lead a LOT of people to flow to this tool instead of the others..
     
    Last edited: Dec 25, 2011
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi,

    I agree with your points on most parts, but I still think having manual placement will be more trouble than its worth - i.e. I believe its possible to get all the features you requested, without actually having the ability to manually place textures within the atlas. I will try to explain why -

    This is certainly a very good feature, and I have added it to the TODO list, and as you say, drawing the sections in there manually is the way to go. This can be done in many ways, and I think it should be a property of the imported texture. So basically, you import the texture, then go into the editor, and say split this texture and position all your splits and name them. This will also solve another problem I was having when implementing the tilemap editor, namely a proper workflow to split up the source textures into smaller tiles.

    We are also using this for our 9-split sprites, etc.

    The reason it can't handle textures 2048 long, is as you say, the padding setting. Its enabled by default when "Pixel Perfect Point Sampled" is unticked. We have since moved the padding out into a setting on its own - this is a much better option, and clearly shows what is happening. You can also add or reduce padding per texture, for problematic ones. Currently when you tick that, point sampling is turned on, i.e. you get blocky textures when upscaling. This is of course fixed, I will attempt to get the next release out as soon as possible to help with this. If you need a temporary fix, drop me an email at support at unikronsoftware.com and I'll sort something out for you.

    This is exactly what the sprite dicing solves... you simply create one source texture (as long as you like, as long as it'll fit the final texture), set the sprite dicing to 100x100 or something like that, and then it will split your texture up into loads of tiny bits (max size as specified before) and reconstruct it automatically for you when you place it in the scene. As an added bonus, it will also tightly fit around any of your textures, so if you had a section which is really thin, you will save quite a bit of texture space.

    I have to agree this is indeed very annoying. We are considering a full revamp of the interface, but really it depends on what people want more - a full revamp of the interface, multi resolution support, or a full GUI system.

    I will try to explain our choices so far though - our internal workflow mantra is generally - the less of our interface we use, the better off we are. That's how we prioritise where to spend time on the interface and such. Generally our workflow is we create placeholder art, start building our game, then send that off to our artists - they simply replace the placeholder textures, and see the results instantly when they save over the texture. It works really well for us, but I can understand it may not for others.

    So far, all our planned upgrades will be free to all existing users, and we have no plans to charge for any updates for the forseeable future. We are focusing on what gets requested most, so if anyone feels strongly about one feature or another, please do let us know.

    Cheers,
    unikron
     
  21. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    First of all, thank you for the detailed reply !
    I would love to know more about the "per texture" setting.. What is the way of changing the padding per-texture ? Is it currently implemented ?

    Also... Is there any harm of using zero padding in all textures ?


    This sounds amazing, I guess I have to dig more to learn more about the features of this tool !

    Once again, thank you for the replies.. I will be posting anything additional here -
    Cheers !
     
  22. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The per texture setting isn't in the current released version - it will be in the next one.
     
  23. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    I would also love to know if there is a way to "force textures" to square... Sometimes the elements can not fill a square area, and becomes problematic in ios..
     
  24. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    I guess I need some support related to fonts..
    I see the fonts have an outline in the demo files, but I can't find the setting for the outline in the TK 2d font settings -
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  26. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This is a valid request and is only a problem with pvr compressed textures. I'll get that added to the next version.
     
  27. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Thank you for the next release news !
    I will be checking the BMFonts website more carefully, I was unable to find anythnig related to the outline of the font --
    The demo fonts have black lines around the letters, I'm not sure if it's made in BM fonts or anywhere else ?
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    To get the black outlines, set up the export options in bmfont as follows:

    BMFont - Export options: 32 bit, Channels A – outline, RGB – glyph and set up the number of pixels for the outline itself
     
  29. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Thank you very much.

    I've also noticed that, when the tk2d text mesh is "flipped", the alignment options does not work..
    I'm testing unity 3.5 right now, and nothing with a tk2d sprite inside can be selected multiple. Want to ask if 3,5 is supported ?
     
  30. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    780
    I wonder whether anyone could give me a couple of pointers. I've scripted a drag and drop movement for moving 2 D sprites in the toolkit. The sprites have a box collider and a rigidbody. What I want to happen is when I drag a sprite and it collides with another, the sprite drag stops, I've tried isTrigger assuming I could just code the stop myself. The sprite doesn't register the collision when it is being dragged. If I put gravity on the sprite and it falls through several others it does register the collisions. I've tried variois collision and rigidbody functions from the scripting reference but to no avail.

    I've tried changing collision detection from 'discrete' to 'continuous dynamic' but to no effect. Can't seem to find anything in the forums which would help. I can code around it but I feel I am missing something obvious.

    Any help would be greatly appreciated.
     
  31. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    What you'll need to do is put the objects in seperate layers, then make it so that the layers don't collide. The collision matrix is under edit > Project settings > Physics
     
  32. JerryCic

    JerryCic

    Joined:
    Dec 20, 2011
    Posts:
    4
    Hi

    Does this product have any tools for setting up backgrounds and parralax scrolling?
     
  33. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    105
    I also upgraded to 3.5. I'm seeing the "Rebuilding Index" dialog a lot. Any workarounds would be appreciated.
     
  34. xcube

    xcube

    Joined:
    Nov 27, 2011
    Posts:
    41
    Hi all.
    I use 2D Toolkit 1.51a
    Tell me please how to move the sprite? I need to pixel graphics is not blurred.

     
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi, to those having issues with "Rebuilding Index" in Unity 3.5, it is because Unity doesn't support filenames starting with a . (period) any more. To fix this temporarily, simply rename this file in tk2dEditorUtility.cs:

    Change
    const string indexPath = "Assets/.tk2d.asset";
    To
    const string indexPath = "Assets/-tk2d.asset";

    and also change:
    AssetDatabase.DeleteAsset("Assets/.tk2d.prefab");
    to
    AssetDatabase.DeleteAsset(indexPath);

    We will be releasing a 3.5 version soon, fixing the other prefab warnings too. Otherwise it seems to mostly work fine.
     
  36. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi,

    Turn on "Pixel Perfect Point Sampled" and commit your sprite collection. This will disable filtering and your image shouldn't be blurred any more.
     
  37. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi,

    We simply use the built in Unity z movement to control layers - by using a perspective camera with multiple z depths, you get parallax scrolling too.

    Cheers,
    unikron
     
  38. DashCunning

    DashCunning

    Joined:
    Apr 29, 2009
    Posts:
    54
    Has anyone else been experimenting with 2d Toolkit and the flash output? I am getting artifacts in flash that I don't get when exported for other platforms (see attached images).
     

    Attached Files:

  39. Kalagaraz

    Kalagaraz

    Joined:
    Aug 26, 2009
    Posts:
    46
    What is the best way to create a sprite at runtime? My game generates the main world map at runtime and I would need to create all the sprites inside the script.

    Would I create a prefab for each type of tile? Grass Tile, Dirt Tile, Sand Tile, etc....? Then create instances of them at runtime? How are they linked to the spritebatcher in that case?

    Thanks,
    Kalagaraz
     
  40. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Here is another question:
    I have animated characters exported from my 3D package. They contain 3 to 5 seperate "planes", which are animated by keyframing (position, rotation, scale).

    I am applying "sprite" to each individual plane in unity3D.. When I turn down the nimations, I have only 1 draw calls, but when I turn on the animations, my drawcalls simply... skyrocket !

    I guess this is because of the "scaled" planes, which are essetial to animate my characters !

    I need a solution for this situation... Thank you.
     
  41. sempoi888

    sempoi888

    Joined:
    Jan 1, 2012
    Posts:
    1
    :confused: can we make facebook game with 2dtoolkit?
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It looks like the texture coordinates are shifted slightly - are you running the flash player output at exactly the same resolution as set up in Unity? Could you try it with "Pixel Perfect Point Sampled" enabled as well, as that will reduce the amount of error, but you won't really be able to scale objects up then.
     
  43. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287

    The easiest way to do this in your case, (assuming you have all your sprites in one collection), is to create ONE prefab from the collection, and then instantiating that - at this point you will be able to do:
    sprite.spriteId = sprite.GetSpriteIdByName("Dirt Tile"), etc.

    To create a tilemap at runtime, create a class inheriting from tk2dStaticSpriteBatcher, and in your Awake() function, fill up batchedSprites with all your tiles, before calling tk2dStaticSpriteBatcher.Awake(). You can also do this with another class manipulating the batchedSprites in the spriteBatcher, and then calling Build() on it.

    Hope this helps,
    unikron
     
  44. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This is slightly tricky, as you are importing your geometry from an external source. If you use a built in sprite, you can use the .scale field on the sprite (as opposed to the transform) to scale it without losing dynamic batching. Unfortunately, you won't be able to animate this field in the animation editor, as it is a property.

    To get around this, you can create a class inheriting from tk2dAnimatedSprite, which has an Update function, and sets the .scale property whenever the values have changed. Let me know if you run into problems with this, I have a class somewhere which does it (but it is unsupported as it was just hacked together for that one purpose)

    We usually find it much much easier to use the Unity animation system as opposed to importing from a 3d package, but of course you or your artists may be much more comfortable using another package.
     
  45. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I don't see why not - you can create facebook games in Unity, 2d toolkit doesn't limit you in any way.
     
  46. DashCunning

    DashCunning

    Joined:
    Apr 29, 2009
    Posts:
    54
  47. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    966
    Just to note that Flash builds doesn't seem to support point filtering at all in the 3.5 developer preview. It behaves like bi-linear filtering no matter what you select.

    I wrote a shader that emulates point filtering for my own purposes. Not sure if that is any help in this. You can find it here.
     
    Last edited: Jan 2, 2012
  48. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    388
    For some reason I'm unable to select multiple sprites in the scene and move them whenever I select multiple sprites (by holding shift) I will get a console error stating Internal Error. persistent object is known in persistent manager and then the selection will revert to one of the sprites. Any quick code fix for this Unikron? It is kind of annoying to move a lot of sprites around as a group quickly.

    Edit: Yes sorry, this was an issue introduced with 3.5.
     
    Last edited: Jan 2, 2012
  49. oliverdb

    oliverdb

    Joined:
    Jan 30, 2010
    Posts:
    165
    I get that one as well..it came in 3.5 preview not sure its connected though

     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi

    Thanks for the shader. It will certainly help those having issues with point filtering not working in flash player.

    Cheers,
    unikron
     
unityunity