Search Unity

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

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

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    how can i animate sliced sprite dimensions? i change it with unity animation. i can see that boundary gizmo changes but sprite is not updated. when i click play and change dimensions it updates sprite dimensions. how can i get updated sprite with unity animation?
     
  2. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You will have to write an adapter, just like when animating any other properties. I think I linked to a sprite adapter a while ago, but here it is again -
    http://2dtoolkit.com/forum/index.php/topic,1604.msg7743.html#msg7743
    This will need to be modified for the properties you want to animate.

    Its not possible to animate .net properties with the Unity animator.
     
  3. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    My game runs in portrait view, so I tried various ratios like 9:16, and 2:3. Come to think of it, I'm not sure I tested the Landscape ratios, so not sure if those had the same issues.
     
  4. jgalvezpa

    jgalvezpa

    Joined:
    Dec 27, 2012
    Posts:
    36
    Hello im trying to add Glow in my sprite, but when i add a shader the sprite goes black or white how can i fix this.
    thanks
     
  5. unikronsoftware

    unikronsoftware

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

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    How are you adding glow, and what shader are you adding?
     
  7. Arrarra

    Arrarra

    Joined:
    Nov 11, 2013
    Posts:
    2
    Hello,
    First of all, thanks for this great product. 2D Toolkit makes Unity even more interesting than it already is for those who love 2D graphics ! :)

    I'm having a small problem with my scene. I think it might come from my lack of experience concerning Unity, since I'm still a beginner, but I've been fiddling about for quite some time and I can't find a solution. Hopefully, you'll know what's wrong !

    So the problem is this : I made a test level using 2D Toolkit for the sprites. Thing is, the game project I'm working on requires a lot of sprites even for the most basic bit of floor, because of the art style. That's why I used a dynamic sprite batcher. Then I set up a light (a simple point light in Unity), and gave all my materials the LitBlendVertexColor shader, which works just fine : the light is shining on my sprites the way it should. But there's an exception : the sprites contained in my sprite batcher appears to be transparent when the light hits them. If I un-commit the batcher, the bug goes away, and I can see that the transparent effect fades away when the sprites are far from the light.

    Here's an exemple image of my problem

    As you can see, the grey tiles on the floor are slightly transparents, so we can see the rocks of the floor behind them.
    What am I doing wrong ?
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    That is really weird. Has it anything to do with the sorting? i.e. do you have everything arranged correctly so it sorts consistently?
    2. What version of tk2d and unity are you using
    3. If you use an unlit shader, does it work better, or is it the same?
     
  9. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Hello,

    I'd like to implement a looping animated background. Now i was wondering what'll be the fasted method. Should I use animatedview, movietexture or should I import the seperate 24 frames into one big animated sprite..? It has to run smoothly on mobile.

    One frame is about 1024x576 pixels. What do you suggest?

    Thanks
     
  10. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    What is the contents of this background? Is there a lot of duplicate data between frames?
     
  11. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  12. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Thanks for your answer :) What exactly do you mean by duplicate data? Do you mean that the frames look like each other and only a view part of it is animating?

    I'm having a looping ocean/water animation and thought this might be faster than realtime water. So every frame is a little bit different due to the waves of the water.
     
  13. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Try putting into a sprite collection, enable dicing (try different dice amounts) and see if it compresses much. It may, or may not - its worth a try anyway.
     
  14. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Ok I'll try that, thanks.

    But do you think a sprite animation for background is always faster than a movie background or does it depend on how much it compresses?
     
  15. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    Grabbed the update from the beta thread, but will have to look at it when I feel well enough. Is it a painless drop-in upgrade, or is there a thread of things to look out for/modify?
     
  16. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    I'd say the movie is the costliest in resources, but if it's the simplest for you and the game doesn't suffer, does it matter? ;)
     
  17. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    There shouldn't be any issues if you're updating from 2.x. If you're updating from 1.x, http://www.2dtoolkit.com/docs/latest/migration_guide.html
    Of course, don't forget to run "Setup for JS" if you're using that feature.
     
  18. Arrarra

    Arrarra

    Joined:
    Nov 11, 2013
    Posts:
    2
    Thank you for this quick response !

    I've tried changing both the Sorting Order and the Z position of the sprites to be sure they're well positionned, but the bug remains. If I use an unlit shader, there is no problem. In fact, even with a lit shader, the transparency problem happens only in the area where the sprites are lit ; if I turn the light off, or set the sprites' position out of its reach, the transparency disappears.

    By the way, I'm using Unity 4.2.0f4 and 2D Toolkit 2.3 (updated it before trying the above, but the problem remains with this new version).

    Also, I tried it in a new project, to check wether it was a problem with my project : I still have the same problem in the new project. Here are the exact steps I took in this new project :
    - Created project, and imported 2D Toolkit 2.3 from the Asset Store
    - Deleted the default camera and created a tk2dCamera, with the default parameters (including the new default Pixels Per Meter parameter of 100)
    - Created a new Sprite Collection, put those two sprites in it : Soil and Tile
    - Only changed one setting on the sprite collection : "Normal generation" to "Normals only" ; then commit.
    - Changed the shader on my newly created atlas to tk2d/LitBlendVertexColor
    - Created a static sprite batcher with two sprites in it, each one with one of my images, with the tile positionned in front of the soil, with a different z position and a different layer order. Commited the sprite batcher.
    - Changed the Ambiant light in render settings, to a darker one
    - Created a white Point light in the scene, positionned it next to the sprite batcher with a lower Z position
    - Ta-dah ! The tile sprite appears slightly transparent, just like before, letting me see the soil through it.

    Did I do something wrong ?
     
  19. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    @Orb Thanks for advice :)

    There's a lot more sprites on the screen also. So I prefer the fastest method, besides that the faster the game will run, the lower spec mobile devices can handle it. But it depends on the difference, is it only 10% faster with sprite method, or for instance twice as fast.
     
    Last edited: Nov 12, 2013
  20. codemonkey73

    codemonkey73

    Joined:
    Sep 3, 2013
    Posts:
    1
    I was looking at buying 2D Toolkit because of the current sale, when I noticed a line that said something like "requires 1 license per seat"? What does this mean? I have >1 computer I use for development, and I sync the Unity project files between them. Can I use 2D Toolkit like that, on both machines? I'm just using the free version of Unity. What about between Mac and Windows Unity dev environments? Sorry if any of this is newb questions, I'm very new to Unity.

    Also, when does the current sale end?
     
  21. Lolko

    Lolko

    Joined:
    Oct 15, 2012
    Posts:
    5
    Hi
    Sorry for my newbie question. Now when Unity 4.3 is released why should I buy 2dtoolkit ? What 2dtoolkit has better from Unity4.3 in 2d features? I do not want to offend or upset by my question but I'm a little confused now.
    Greetings
     
  22. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    We use 2D toolkit and plan to use 4.3's features with it. I note the latest 2D toolkit update integrates 4.3 features. It still does so many things 4.3 simply doesn't (because 4.3 is general use and 2D Toolkit is built from constant feedback). If it's on sale now I'd suggest it be a no brainer.
     
  23. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    That sounds really weird. Definitely not seen it before. Can you zip up your simple repro project and email it to support at unikronsoftware dot com?
     
  24. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can use 2D Toolkit on both of your machines, Mac, Windows doesn't matter. All features are supported in the free version of Unity as well.
    The sale ends in 4 days.
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Sure.

    I've posted some of the features here:
    http://2dtoolkit.com/forum/index.php/topic,3081.msg15127.html
    I'll post a better link once I've written it up properly.
     
  26. Vidd

    Vidd

    Joined:
    Jun 3, 2013
    Posts:
    7
    I'm interested in creating a 2D platformer that will involve slopes. From what I've seen, this requires a custom physics implementation as otherwise you get characters hopping off slopes on the way down (or at the top) or struggling upwards, rather than having a uniform speed.

    Is this easy enough to implement in Toolkit 2D?
     
  27. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    Just updated last version and unity 4.3, i was affraid something gone bad, but all my scenes work well after hours of tests:D
    good work Unikron.
    I havent heard of the 2d Physics change, how is it different ? should i change something on my "old physics" behaviors?
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    2D Toolkit manages the colliders for something like this, and the tile map system if you use it, will create optimized colliders for you.
    If you think the built in Unity character controller (there isn't one for 2D physics yet) isn't suitable you could of course roll your own ray cast based one. That should give you pretty good results. You can also try Prime31's character controller 2D https://github.com/prime31/CharacterController2D
     
  29. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can try the new 2D physics engine in Unity if you want. Here are some notes on how to switch physics engines: http://www.2dtoolkit.com/docs/latest/unity_43_integration.html
     
  30. mikhail111777

    mikhail111777

    Joined:
    Feb 8, 2013
    Posts:
    84
    Good day.

    It looks like PNG altas doesn't work, when there are embedded fonts:

    IndexOutOfRangeException: Array index is out of range.
    tk2dSpriteCollectionBuilder.Rebuild (.tk2dSpriteCollection gen) (at Assets/TK2DROOT/tk2d/Editor/Sprites/tk2dSpriteCollectionBuilder.cs:1298)
    tk2dSpriteCollectionEditorPopup.Commit () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:446)
    tk2dSpriteCollectionEditorPopup.DrawToolbar () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:436)
    tk2dSpriteCollectionEditorPopup.OnGUI () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:889)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  31. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Indeed it is. It will be fixed in the next hotfix, but if you need this super urgently email support at unikronsoftware dot com and I'll sort out a patch for you. Apologies for the inconvenience.
     
  32. Vidd

    Vidd

    Joined:
    Jun 3, 2013
    Posts:
    7
    Thanks for the quick reply. I purchased Toolkit 2D and look forward to trying it all out. :)
     
  33. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The Other Brothers used both the unity capsule character controller then later in development I rewrote all physics to be raycast based with a custom solution. Both behaved the same, I basically felt like doing it.
     
  34. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    Hi unikronsoftware, can you say some words about why we continue to use 2dtoolkit sprite system that uses mesh renderer instead of Unity's sprite system that uses Sprite Renderer.
     
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  36. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
  37. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    We seemed to be noticing this error more recently on our tk2dUIUpDownButton gameobjects when we click on the buttons and they are in a down state.


    Yet, the OnButtonUp() method is fired despite the ButtonGraphicUp not being active.

    I was wondering if you might have any suggestions at what to look at to fix the error?

    We'd like it so that the player clicks on a button down, and when they release the button the OnButtonUp is fired, but the error fires everytime.

    Edit:
    So it would seem removing the tkUITween component from the ButtonGraphics prevents the error from happening. That makes sense as that is for buttons that scale on touch rather than change image.
     
    Last edited: Nov 18, 2013
  38. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This seems to happen when the tween item is on the wrong level of hierarchy - it should always be on an object that isn't disabled. This requirement is likely to change in a future version though.
     
  39. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Does it cause issues to have multiple Tilemaps within the same scene?

    I ask this because we were having an issue where we wanted have a tilemap with two layers, but have separate tilesets per layer, but currently your tilemap editor does not support more than one tileset per tilemap.
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Nope, its fine. We did plan for that use case.
     
  41. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    54
    I'm having a problem using 2DTK with the latest version of unity. Even the demo scenes produce an error:

    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(150,25): error CS0103: The name `tk2dUtil' does not exist in the current context
    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(214,41): error CS0103: The name `tk2dUtil' does not exist in the current context
    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(224,25): error CS0103: The name `tk2dUtil' does not exist in the current context
    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(288,33): error CS0103: The name `ColliderBuilder2D' does not exist in the current context
    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(501,25): error CS0103: The name `tk2dUtil' does not exist in the current context
    Assets/Plugins/tk2dTileMap/Code/tk2dTileMap.cs(585,25): error CS0103: The name `tk2dUtil' does not exist in the current context

    Any help would be appreciated
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Have you run Setup For JS after installing?
     
  43. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    54
    Yes. I made sure I did that and the error still exists.
    I even started a new project and did it and also tried deleting the 2DTK files from an existing project, then installed 2DTK then set it up for JS and the error still exists. When I do integrity check I get "Success"
     
    Last edited: Nov 23, 2013
  44. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    is there any ETA for 2D collider's on Sprite Collection Editor?
     
  45. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  46. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    limitations item 2

    2D Toolkit UI currently only works with Unity 3D colliders. This will change in a future version.

    i select 2d physics on sprite collection settings but cannot see 2d collider types on sprite collider type
     
  47. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    That limitation is specifically for 2D Toolkit UI - that is just used for ray casts right now.
    Once you switch the 2d physics, just commit. The correct collider types are mapped automatically. Eg box -> BoxCollider2D and so on.
     
  48. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hmm. This is really weird. I just tested this with 2D Toolkit 2.3.0 final, from both our website and the asset store in an empty project and it seems to work fine. What versions of Unity and tk2d are you using here?
     
  49. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    how can i make circle collider 2D with it?

    Edit: also it removes physics material on each commit. i used polygon collider.
     
    Last edited: Nov 23, 2013
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This is intentional for parity with the 3D collision system. You can still set the collider type to Unset and manually set a circle collider if you want.

    That is a bug, please report it on our forums so it doesn't get forgotten about. This thread is a bit unmanageable :)