Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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
    Have you run a profile to show you whats slow there? It could potentially be the texture being uploaded to VRAM the first time its rendered...
     
  2. andmm

    andmm

    Joined:
    Nov 21, 2013
    Posts:
    37
    Hey Unikron, your site is down since yesterday.
     
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hey seems to work fine for me, not had any downtime at all - does it work for you now?
     
  4. andmm

    andmm

    Joined:
    Nov 21, 2013
    Posts:
    37
    Nope
     
  5. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hmmm... so bizarre. Just checked, no downtime until now. Who is your ISP, could possibly be blocked for some reason?
     
  6. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    There is no tk2dUI manager script in my scene. it uses the tk2dUICamera script and there isn't an option for this.
     
  7. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Add a tk2dUIManager script to an empty game object, you can set it on there.
     
  8. Maklaud

    Maklaud

    Joined:
    Apr 2, 2013
    Posts:
    551
    Hello! I got a copy to test and have some troubles now. Can you help me, please?
    The only thing I need from tk2d is localized texts (TextMesh, right?). I don't have time to read all the documentation, so I just started from your camera and text mesh.

    The first moment which is really terrible to me is your camera. Why do you think I must remove the unity main camera and replace it with yours? Ok, I did that. But I have my own scaling system and it works well in every screen size. After adding your camera the game looks a bit strange, especially the text mesh.

    I also had a few text mesh questions, but solved it myself while was writing this message :)

    Frankly, now I'm a bit (very!) confused because of this plug-in. I think it should help people to solve the tasks very quickly, but now it just makes different problems. At least its own scaling system which overrides mine. Can I switch it off?
     
  9. Maklaud

    Maklaud

    Joined:
    Apr 2, 2013
    Posts:
    551
    How to know TextMesh size in pixels? E.g. I set its text with line breaks (say, 3 lines of text) and I need to know its height to place it accordingly (a bit higher that the center of the screen). How can I do that?
     
  10. Maklaud

    Maklaud

    Joined:
    Apr 2, 2013
    Posts:
    551
    Well, and no answer. You know, the more I try the plug-in the more I understand it's worthless. It's difficult to set position for the text, anchors don't help well. It's difficult (or impossible?) to calculate the real size. The the support is terrible. Thanks to me I didn't pay for THAT.
     
  11. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi, we usually answer support questions within 24 hours, but we've been away at a trade show without any internet access, so I apologise for that. We're back now, email support at unikronsoftware.com and we'll get this resolved ASAP.
     
  12. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Can we get a overload for sendRawMessageToPeers that exposes the length parameter for byte[] parameter? I see its used behind the scenes as a dll imported function. Currently, I just modified the .cs file and now have access to it, but would like it to be a permanent change so that when I update the code, I don't have to integrate any custom changes on my part. I need this because I now reuse byte[] buffers in set block sizes, so that I don't have to allocate a new exact size byte[] every time I need to send data.
     
  13. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  14. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Dammit. Yeah I posted on wrong thread...
     
  15. Eklavyaa

    Eklavyaa

    Joined:
    May 4, 2014
    Posts:
    20
    Hi,

    I have created the levels using TileMap. There is a character which moves from left to right and tile maps are already placed manually in front of this character in the scene. There is tk2dcamera which follows this character. Script applied to camera is SmoothFollow.Js which comes with Unity.I have placed 13 levels one after the another with same Bg, Bg is repeated 13 times.

    -When character moves the edges of the tiles jitters , just the edges.

    I have tried following options , but nothing helped .

    1. Putting code to move the camera in LateUpdate instead of Update in the SmoothFollow.js .

    2. Replaced tiles with there corresponding prefabs , applied rigidbody to prefabs and tried interpolate/extrapolate .

    3. Increased the position iteration from 3 to 8.

    4. The code which moves the character is

    Code: [Select]
    transform.position += m_MoveXBy * Time.deltaTime
    m_MoveXBy- > a vector with only x value defined rest are zero.
    inside the update.

    5.Instead of moving the camera and character I tried moving maps and keeping character stationary . But still jitters

    Please let me know how I can overcome this problem.

    PS: Character has rigidbody , is not kinematic , interposlation is None , gravity is 1.5. Any help is much appreciated.
     
  16. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I've replied to your post on the tk2d forum - please reply to that.
     
  17. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    Hello!

    How would you get this kind of lighting working on mobile?

    https://pbs.twimg.com/media/B1goA9FCAAA2dVb.png:large
    https://pbs.twimg.com/media/Bvd15uYIMAAM07E.png:large
    https://pbs.twimg.com/media/Bu87t1gIMAA-gaw.jpg:large
    https://pbs.twimg.com/media/BunQBr8IUAAVM40.png:large

    Here's how they do it, according to the author:
    "We use 3 layers: day version, night version with holes in it to reveal the day version, and additive glows. All background assets exist in 2 versions: dark with low/no detail and day with details"

    How would you go around implementing this sort of lighting technique?

    Since I'm targeting mobile, I'd need a shader-based solution to blend between the night/day textures, rather than having to render the scene twice.
    I think the best option is to write a shader which used per-pixel light intensity to blend between two textures (day and night), but I'm not sure how to deal with all the atlasing going on in tilemaps and sprites.

    How would you go about it?

    Thanks
    nacho.
     
  18. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,269
    Hi,

    Is there a way to grab the current texture playing per frame in an animated sprite in real time, in code ? Considering there is an altas the frames are played from and i need the part of the atlas that corresponds to the current position of the animated sprite.

    I want to apply that texture (part of the atlas) to another script as texture input for processing.

    Also what is the performance impact in doing it, if it can be done.

    Thanks
     
  19. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    1. Create 2 versions of each sprite, night and day.
    Use linked sprite collections to create 2 atlases in parallel. (tk2d 2.5 beta feature)
    http://2dtoolkit.com/forum/index.php/topic,4441.0.html

    2. Create a custom shader that takes 2 textures and blends them with a third. The 2 textures are naturally the ones created above in step 1. Texture #3 uses viewport space as the uvs.

    3. Texture #3 is a screen sized (or smaller) light accumulation buffer. Glow sprites only draw into this buffer using layers.
     
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can use tk2dSprite.CurrentSprite.positions / .uvs returns the points that form the quad and the uvs from the texture. Performance hit should be negligible.
     
  21. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    didn't know about linked sprite collections, that's just the piece of the puzzle that I was missing.
    awesome stuff!
     
  22. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,269
    Thanks a lot, very usefull
     
  23. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    hello again
    I've been meaning to ask this for months but never got round, sometimes I get "gaps" between tiles. it happens quite often when working on my mac, and also happens (rarely) when I run the game on iPhone. please take a look at the screenshot.
    any idea how to fix this?

    I've also attached screenshots of the spriteCollection settings and spriteSheet settings.

    thanks!

    tileError.png
     

    Attached Files:

  24. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Try setting pad mode to extend + amount to 1/2. Might work better in this case.
     
  25. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Hi, just wondering, are you dropping the support for Unity 3.5.7 on 2D Toolkit?
     
  26. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Yes, but you can get an older version that works on 3.5.7 (version 2.3 or below) on the Releases page on our website.
     
  27. Vordas32

    Vordas32

    Joined:
    Sep 9, 2012
    Posts:
    15
    Hi, I just start working with 2D Toolkit and I need to say that it's great tool for 2D games. I just start to devoloping new 2D game for Android market but I have one issue. I mean to create 2D Memory MatchUp game. So I have cover sprite and card sprite which is child of cover sprite. On both sprites is atlas texture from 2D Toolkit and one material on both sprites. On material I set shader like is on defult "tk2d/PremulVertexColor". My problem is when I rotate cover sprite in inspector panel on y-axis I get weird rotation and also when I animate rotation with animation view on y-axis. Rotation is not 3D it's like spin out. To see what I mean see image below


    It's weird rendering in game view when I rotate cover sprite which is on top-right corner in scene view.

    Please can I solve this problem and how do I solve it? I was trying to solve by changing shaders and I was trying them all but still nothing changes. I build game for web player on google drive so you can see how sprite weird rendering when it's rotating on y-axis: http://googledrive.com/host/0B5uli9YhlHZxQmlpQWhlMm1wcGM

    I first start create game with Orthello 2D and with this framework and don't have this problem but I want to create game with your tool because game is for androind market and Orthello 2D have not so good mobile performance like 2D Toolkit. I upload game to google drive created with orthello so you can see what I really want regarding for rotating sprites, if is posible with 2d toolkit. Game is playable but not finished:http://googledrive.com/host/0B5uli9YhlHZxNnduV1BzS3B4R2s
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi,
    It looks like the sprites are too close / too far away from the camera. Pull the camera away from the sprites and it should work better, make sure there is enough room for the object to rotate in the z axis, you might need to change the far clip plane too.
     
    Vordas32 likes this.
  29. Vordas32

    Vordas32

    Joined:
    Sep 9, 2012
    Posts:
    15
    Thanks. I pull the camera away on z-axis and now it's rendering properly. I never assume that this can be the problem, I never work before with 2d toolkit. Thanks again.
     
  30. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Updated to Unity 4.6 and I'm now getting some odd behavior. Went to edit some levels that have perfectly aligned sprites. The sprites I haven't touched still work great, but if I move them as a group, from then on tiny gaps can appear when the camera moves or orthographic scale changes. The sprites are already set to 'extend' padding.



    The platform to the right is a duplicate of the platform on the left. If I move the platform on the left, it has the same problem. If I undo the move, it's back to being perfect. If I manually position the sprites again (holding V), it has the problem. Any ideas?

    edit: updated 2dtk.. seems to have fixed that issue, but now I have other stuff to fix.

    edit2: ok, that's annoying. If I have "Enable sprite controls" it fixes the problem, but when I turn that off it breaks again. But those sprite controls just get in the way (I don't need to stretch anything). Also having weird rigidbody behavior after updating 2dtk somehow...

    edit3: animatedSprite.IsPlaying("Fire") is now returning true when a different animation is playing. That's not helpful. edit4: was able to fix that one in the source -- seems to fix my rigidbody problem too, so I must have had that tied to current animation or something.

    edit5: ended up going to 4.5.5p5 instead of 4.6
     
    Last edited: Dec 11, 2014
  31. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hey, drop me an email at support at unikronsoftware.com, I'd like to get to the bottom of this.
    Need to know what version of tk2d you were using prior, what version of Unity you were on. The animator hasn't changed in absolutely ages, so that sounds really dodgy too, deffo worth getting to the bottom of this.
     
  32. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Everything seems to be fine in 4.5.5p5 with the old version of 2dtk I'd been using (this should give me access to iOS 8 / Xcode 6) so I think I'm good for now.

    It was ages since I upgraded 2dtk heh -- I'm still on "1.92 final + patch 1" -- when I upgraded to 2.5.0 it notified me I was using the depreciated animated sprites (very far in development -- want to avoid upgrading things if possible), so I guess this only applies to the old system, but if you want to fix it the bug is on line 196 of tk2dAnimatedSprite.cs in 2.5.0 off the asset store

    Checking isPlaying using string to identify clip wasn't actually checking the string.
    Code (CSharp):
    1.     public bool IsPlaying(string name) {
    2.         return Animator.Playing;
    3.     }
    changing it to below got my animations changing properly again
    Code (CSharp):
    1.     public bool IsPlaying(string name) {
    2.         return Animator.IsPlaying(name);
    3.     }
    The tiny flickering gap problem:
    • "1.92 final + patch 1" + 4.4.3 & 4.5.5p = perfect
    • "1.92 final + patch 1" + 4.6 = tiny gaps
    • 2.5.0 (with "Enable sprite controls" enabled) + 4.6 = perfect
    • 2.5.0 (with "Enable sprite controls" disabled) + 4.6 = tiny gaps
    Those sprite controls were kind of cumbersome when trying to move several small sprites at once, so it'd be nice to be able to disable that without breaking perfect tiling if I ever upgrade again. I don't know exactly how your tiling system works, but it felt like 4.6 introduced some sort of micro-grid and your sprite controls were overriding it to retain perfect tiling.
     
    Last edited: Dec 11, 2014
  33. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You're indeed correct, IsPlaying is a bug in the tk2d 1.x compatibility layer. Thanks!

    I'm going to investigate this, but in the mean time you can simply disable it in preferences...
     
  34. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Right, but disabling sprite controls brings the flickering gap problem back in 2.5.0 / 4.6.
     
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hmm.... very confusing - the sprite controls is purely an editor thing... not sure how that could affect it? Maybe I misunderstood that. How are you aligning these sprites? By position or using V?
     
  36. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    I hope this goes on sale sometime soon. Really looking to buy it.
     
  37. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    Hi!
    We love 2Dtoolkit, and we are doing our second game with it.
    We are using the tilemap heavily

    We are doing an horror movie game:
    http://www.machiavillain.com/

    Nothing is right and parallele in our world
    But we want to make the tilemap less clean, by adding noise on the vertex position.

    Where is the best place to do this in the code to insert a noise function on vertex position ?

    Thanks.
     
  38. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The easiest and least intrusive thing will be to do it in the vertex shader.
     
  39. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    And in an intrusive maner (it's more simple than modifying each shader I want to try on the tilemap).
    Don't worry I already hack in 2D toolkit :)
     
  40. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,121
    Hi Unikron! I'm having a new and weird issue after getting a laptop and installing the latest unity & 2d toolkit
    Unity3d 4.6.2f1
    2d toolkit 2.5

    What happens is, I create a new sprite collection and give it a name. However when I open it and try to drag a sprite to add to the collection my cursor gets the visual of "cannot place item" (a circle with a diagonal line), and I cannot add any sprites. In other projects, where everything was previously fine, and in the demo of 2d toolkit 2.5 when I open "DemoSpriteCollection" the "drag sprites here/sprites list" is missing entirely. Could this be because of the resolution of the laptops screen? its 1366x768, Win 8.1
    I tried dragging the editor window to make it bigger, maximize it, etc, but to no avail, also tried creating new/empty projects for testing but same thing.

    Thanks in advance!
     

    Attached Files:

  41. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Sorry for missing the post, I wasn't signed in and didn't see the notification :(

    Can you resize the panel to the left? Drop me an email and we should be able to resolve this quickly.
     
  42. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,121
    Hi! Yes, I tried resizing the panel but to no avail
     
  43. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    have you tried "Reset Editor Sizes" in tk2d preferences?
    If you've done that and it doesn't work, drop me an email at support - I'll get you a patch to hardcode the size
     
  44. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    I've been using various other UI solutions for years, but am looking for a new solution for in-game HUDs, panels, scrolling windows, button bars, loading bars, etc.

    I am encouraged by the positive feedback this package has received, but I'm reluctant to spend $75 to test it out. Is there a demo version, or possibly a discount price sale coming up?
     
  45. unikronsoftware

    unikronsoftware

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

    Drop me an email at support at unikronsoftware.com - I might be able to sort out an eval. There isn't a demo because the package is distributed as source code. No upcoming discounts that I am aware of either.
     
  46. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,121
    Hi! Sorry for the late reply, yes, that solved the issue! :)
     
  47. ChrisRuss

    ChrisRuss

    Joined:
    Jun 24, 2013
    Posts:
    1
    Hi,

    What is the best way to upgrade tk2d to the latest version? I would like to upgrade my current unity 4.x project to unity 5.
     
  48. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Update it on the asset store, then upgrade unity to 5.0. Should work unless you're on an ancient version, but I think you're probably not on such an old version if you've been working with this in 4.x
     
  49. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    I'm considering purchasing 2D toolkit but I need to know something that is critical to what I need.

    First thing: one problem with 2D games is that sometimes placed tiles will look normal but actually start having "glitches" when the camera moves, for example seams might show between each tile or sprites might end up having weird scaling approximations.

    Does 2D toolkit solve that issue? Will I be able to use 16x16 pixel sprites without any problems and have a proper camera able to scale the pixels correctly?

    Second thing: my character controller only recognizes collisions with objects on the "platform" layer, would I be able to define on which layer the tiles end up to and properly manage colliders so that they would work with this same system?
     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hmm, I don't know why I didn't get a notification for that post, sorry for the late reply.

    1 - It depends, and there are workarounds if you have issues. Eg. tk2d will create correctly padded tiles and you can add padding to avoid the usual unsightly seams. Can't help if you're not rendering pixel perfect though, eg. if you're rendering at some weird 1.3x scale, you're gonna get doubling whichever way you do it.

    2 - Yes, you can have unity layers associated to tilemap layers.