Search Unity

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

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

  1. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    renderer.material creates a unique copy of the material for use there, but that will be lost as soon as you change sprite, as tk2d will reassign the material. You could possibly stop it doing that, but you should somehow manage this manually - each duplicated material will end up costing a unique draw call...
     
  2. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    i want to use unity physics. what do you suggest for camera and sprite collection settings? i want to use real dimension sizes. for example i have a ball game and i want to make my ball size as 20 cm.
     
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Measure the size of your ball in pixels, then use the same pixels per meter setting in the tk2dCamera (2D Toolkit 2.2 and above) and sprite collection. That should be it.
     
  4. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    40
    Hello Unikron,

    I'm planning to upgrade to unity 4.2 because of the 2d physics.
    I don't want to use the new native sprite stuff in unity because it seems a bit lacking still and it doesn't have tilemaps.

    Will 2dtoolkit play nice? (I use animated sprites and tilemaps)

    thanks
    nacho
     
  5. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It works fine in 4.3 (though there are a lot of undo related warnings which will be fixed in a future release). Tilemaps don't work with 2D physics yet - we'll definitely implement support in the next major 2D Toolkit release.
     
  6. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    40
    found what seems to be a little bug

    if you set the frame without actually playing an clip, but instead using:
    spriteAnimator.SetFrame(1);

    the correct frame is set but spriteAnimator.CurrentFrame will return 0 no matter what.

    thanks
    nacho
     
  7. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    do you mean 2dtoolkit will support rigibody2d and 2d colliders in unity 4.3? also will you support polygon collider? if answer is yes will it supply whatever 2d collidergen offer?
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It will support the new 2D rigidbody stuff + colliders. Still unsure how the poly collider integration will work, the priority is to get it all integrated nicely first. Still unsure about automatic poly collider generation - it depends on how we can interface with the Unity stuff, the initial implementation will be exactly whats there now, but working with the 2D physics system in addition to Physx.
     
  9. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Your'e right this does look like a bug. I'll make note of it for the next version. Thanks for reporting it.
     
  10. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    We created a spritesheet from a spritecollection atlas that we made in 2D Toolkit. From there we used the spritesheet on a tilemap. We noticed the Palette on the Tilemap, orders the tiles, differently then how they are ordered on the spritecollection atlas.

    This becomes a problem when we open the Tiled app to make a TMX file, and we have to make the tileset for Tiled from the spritecollection atlas. Because when we import the .TMX file it ID's the tiles based on their pallete order and not the spritecollection atlas order. Is there a way to adjust or fix this issue?

    Tiled App with the spritecollection atlas texture:
    $screenshotTiled_post.png

    Palette within Tilemap Editor in Unity:
    $screenshotPalette_post.png

    Edit Note:
    This seems be a different issue then the one I had with tiles importing incorrectly before, as this is palette related.
     
    Last edited: Oct 11, 2013
  11. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Making the tiled palette using the sprite collection atlas is not a good idea. The order is undefined, and the sizes may not be regular, depending on your source textures. Simply create a spritesheet yourself if you have a regular grid of sprites and feed it into both tiled 2d toolkit (using sprite sheet import).
     
  12. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    in flash building i get this error. how can i solve it?

    C:\Users\IS95166\Documents\Projects\AnimaKB\Trunk\IsCep\Temp\StagingArea\Data\ConvertedDotNetCode\global\tk2dUIDemoController__MoveProgressBar_c__Iterator11.as(59): col: 14 Error: Access of undefined property _0.
     
  13. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can try removing the UI demo scripts - tk2dUI_demo / tk2dUI*.cs
    That error is from one of those.
     
  14. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    Thanks Unikron. That's good to know. This is just a suggestion to avoid confusion for others later, but perhaps in the TileMap Tutorial on your website you should mention this in explicitly in a special note.
     
  15. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    Is it ok to use more than one TileMap in a scene with the same spritesheet, or does that incur extra draw calls. and collision data?
     
    Last edited: Oct 12, 2013
  16. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    If you add a second tilemap it will be completely separate to the first, with its own render and collision data.
    It will increase draw calls as the meshes will likely be too large to merge, but the defaults are optimal values for a completely populated partition, merging any more will likely be detrimental to performance.
     
  17. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Added a note.
     
  18. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    with new version i get this error on flash build. i examined your code, as i undestand you disabled BuilderUtil with flash build.

    Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs(190,17): error CS0103: The name `BuilderUtil' does not exist in the current context
     
  19. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    What version of Unity are you using with flash here?

    That quite possibly doesn't work - we've not bothered testing with the flash version since Unity isn't going to be updating it anymore. Once again though - if you're not using the tilemap, you can delete the tilemap folders (Get 2.2.2 first though, older versions accidentally had a dependency in the core codebase to tilemaps). We're still happy to support it to at least get it to compile and build though.
     
  20. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    Recently, we've been noticing screen tearing on our tilemap. We were using v.2.2 and were wondering if you might recommend things to look at to possibly solve this issue? It's very noticeable with camera movement.

    Normal image:
    $NormalSloth.png

    Screen Tear:
    $ScreenTear.png
     
    Last edited: Oct 16, 2013
  21. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,123
    I think you can get rid of those, when you select the Sprite in the Collection and set the "Pad Method" to "Extend"
     
  22. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Yup, extend should more or less get rid of them completely. If youre using point filtering (doesn't look like you are), also increase padding to 1-2 from Default.
     
  23. EvilNoodle

    EvilNoodle

    Joined:
    Nov 17, 2011
    Posts:
    27
    Hi,

    Loving the new version with tilemap support!

    Do you have any plans to implement an area of interest system to dynamically disable tile collisions, rendfering etc for tiles beyond an actication distance from one or more objects?

    Cheers

    EvilNoodle
     
  24. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    I already have the Pad Methods set to extend. I tried increasing the padding to 1-2, but that doesn't seem to work either.
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Are you on PC/Mac, and do you have multisampling turned on? Also, do you have mipmaps on on the sprite collection? This definitely can work, but with Unity being as open ended as it is, any number of things can cause the issue to manifest - just have to narrow things down.
     
  26. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Not yet. We're planning a more dynamic tilemap system - the whole thing is pretty much held back by the Unity collider system right now, being too slow to update at any decent framerate. We're constantly reevaluating the situation to see how we can do this better, while still keeping the system as generic as it is right now.
     
  27. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,193
    I'm currently working on a Mac with the iOS build settings. I do not have mipmapping on for the sprite collection. And multi-sampling is currently disabled.

    You did lead me to the overall solution though, which is that on our QualitySettings we had Texture Quality to Half-Res. Changing it to Full-Res fixed everything. Thanks.

    Regarding this, if we did want to have half-res textures is there a solution for this?
     
  28. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Will the 2DToolKit will be 'Sherlocked' by Unity 4.3's new 2D features?
     
    Last edited: Oct 17, 2013
  29. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    If you want half res textures you'd have to add even more padding. It is solveable, but will require additional padding so it filters correctly.
     
  30. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Unity 4.3's 2D features are pretty much just sprites 2D physics - check the videos / posts to find out what you'll be getting there. You're out of luck / need to roll your own if you need anything more than just plain old sprites - 2D Toolkit provides a lot of those missing features. Eg. clipped / tiled / sliced sprites, a quick way to perform sprite animation, pixel perfect sprites, 1x, 2x atlas swapping, bitmap fonts, tilemaps, UI, etc. I'm not gonna bore you with a feature list :) A lot more details here: http://www.2dtoolkit.com/features.html

    We'll be releasing a 4.3 compatible version (using the 2D physics engine) soon, hopefully in time for the 4.3 public release.
     
  31. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114
  32. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Yes :)
    For starters (and this is confirmed), we'll be hooking into the 2D Physics engine. Hopefully in time for the 4.3 release.

    Not sure about the atlasing stuff, we do a lot of manipulation with the textures (edge filtering, dicing, etc), which isn't possible with unity's atlasing solution. We'll wait and see with that one.
     
  33. Balint

    Balint

    Joined:
    Sep 24, 2013
    Posts:
    10
  34. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
  35. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    So to keep it short and sweet... Does this mean that you'll be integrating 2DToolkit with Unity's 4.3 new 2D features as seamlessly as possible?

     
  36. unikronsoftware

    unikronsoftware

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

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Where it makes sense, absolutely :)
     
  38. EvilNoodle

    EvilNoodle

    Joined:
    Nov 17, 2011
    Posts:
    27
    Hi,

    Thanks for your reply about the area of interest thing. When you say updating colliders is slow do you mean disabling/enabling them in the tile map or swapping them out for different ones. I had planned to roll my own AOI system if it wasn’t on your roadmap but if switching the colliders on/off is going to introduce its own problems then I will hold off until that improves when it sounds like you plan to address it anyway.

    A couple more questions:

    1) The limit of 1024*1024 tiles. I have no idea if it would perform ok or not but I would like higher limits here. For example: for a long moon terrain I might only need 64 height but want 2048 width. I know where the code that sets these limits is and can change them but I wanted to know what the impact of future updates would be in this case. For example say I modify the limits to 2048*2048 to achieve the above. Will my implementation break when a new release comes out resetting them to 1024*1024 (bits of map getting deleted etc.) or should I just be able to re-set the limits to my desired values and have it work as intended.

    Edit: Just answered this one myself. It seems fine to modify the max sizes as they only seem to get applied when you try and re-size a map. As long as you modify the code to set them back to what you want before resizing any maps it shouldn't be a problem.

    2) The tools for flip horizontal and vertical appear to have shortcuts mentioned in their tooltips (H and J) but they don't appear to work. Any chance of these being implemented? Those combined with a keyboard shortcut for rotate would be awesomesauce!

    Cheers again!

    EvilNoodle
     
    Last edited: Oct 19, 2013
  39. Balint

    Balint

    Joined:
    Sep 24, 2013
    Posts:
    10
    Then it is not released yet?
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    That video you linked is the system in the next version of Unity, I have no idea when that will get released, and that isn't our software, 2D Toolkit.
     
  41. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    1. Those are simply UI limits, increase to whatever you like - as you've found out, it only uses them when resizing.
    2. The flip shortcuts definitely should work - make sure the scene view has focus - try clicking in it once and try the shortcut again? Does that help?
     
  42. EvilNoodle

    EvilNoodle

    Joined:
    Nov 17, 2011
    Posts:
    27
    Hey,

    You are right the H and J shortcuts do work - my bad. Any chance of one for rotate as well to round off the set?

    On another note what are the correct px/metre settings for 16*16, 32*32 and 64*64 px tiles respectivly as I have had some trouble getting this right for seamless tiling. Either the tiles end up too small in their cells leading to gaps between them or too big resulting in overlap. The closest value I found for 64*64 seemed to be 19 but that still isnt properly aligned with the cell boundary.

    Edit: Hmm perhaps I was making a mistake with power of 2 tiles. If I use 30*30 tiles or 60*60 it works a lot better as it is more cleanly divisible. Is that how this is intended to be done?

    Any ideas?

    EvilNoodle
     
    Last edited: Oct 19, 2013
  43. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Pixels per meter shouldn't affect how far the tiles are apart. That is set up in the tilemap settings tab, under tile properties. You set up the tile size there, but you'll need to update it if you change the pixels per meter setting.

    I'll add a shortcut for rotation in the next version. If you wanna patch it into the current version, look for these lines in tk2dTileMapSceneGUI.cs
    case 'h':
    ev.Use();
    tk2dTileMapToolbar.workBrushFlipX = !tk2dTileMapToolbar.workBrushFlipX;
    UpdateWorkingBrush();
    break;

    Duplicate them, swap 'h' with the key you want ot use for rotation, and then change workBrushFlipX to workBrushRot90 in the copy.
     
  44. EvilNoodle

    EvilNoodle

    Joined:
    Nov 17, 2011
    Posts:
    27
    Thats awesome dude cheers!

    EvilNoodle
     
  45. Vladsmesh

    Vladsmesh

    Joined:
    Oct 20, 2013
    Posts:
    1
    did tilemap, but no colliders. Did I miss something?
     

    Attached Files:

    Last edited: Oct 20, 2013
  46. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    You need to define the colliders for the tiles on the sprite collection, I think
     
  47. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    i will prepare an iPhone Application demo. i have screenshots. i can define a polygon and UV map and make a material for this polygon with my screen shot. i can animate material image to change screenshot. how can i do this with 2dtk without making an atlas with my 100 screenshot?
     
  48. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,307
    Hi guys,
    Just wondering if anyone knows the export settings from BmGlyph... I can't seem to get it to work this time :(
    I've tried them all... but I thought Cocos2d was the one



    These are the files that get output


    Any ideas?
    Thanks
    Pete
     
  49. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The cocos setting works fine for me. Please email the font (fnt png) to support at unikronsoftware dot com and I'll investigate.
     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can use tk2dSprite.CreateFromTexture to create a sprite with the right size. You can also create a sprite collection at runtime, and then change the texture assigned to it as you would normally. Check sample #13 - it has a few different examples of creating sprites from textures at runtime.
     
unityunity