Search Unity

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

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

  1. Rogetsss

    Rogetsss

    Joined:
    Jul 11, 2012
    Posts:
    12
    Hi!

    I'm working on a game using 2d Toolkit, but I am facing an issue. The artists asked me to increased the resolution of the font so it doesn't look pixelated. Fine for me, I re-exported my font bigger using BMFont, but it seems that now the fonts are just bigger in the game and doesn't fit buttons anymore. Is there a way to have a "scale" parameter in the font or something that I could do to avoid resizing all the labels in the game to fit the new font size? This could happen frequently too. Like in a bug-fixing phase, when you need to increase the resolution of a font, you don't want to change all the labels. :O In NGUI, all the labels are in absolute size, and are not dependant of the font itself. Is there something that we can do?

    Thanks!
     
  2. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can scale the pixels per meter / ortho size field on the font proportionately and commit to rescale the font globally.
     
  3. Rogetsss

    Rogetsss

    Joined:
    Jul 11, 2012
    Posts:
    12
    Oh gawd thanks! I missed that! I was trying to figure out how the size worked, but forgot to press "commit" ... -_- Thanks again!
     
  4. Eklavyaa

    Eklavyaa

    Joined:
    May 4, 2014
    Posts:
    20
    Hi,

    After successfully creating a small demo of platform scroll, I am trying my hands on Animations.

    But I am not able to create the sprite collection. I followed these steps:-

    1> created a sprite collection prefab , from create->tk2d->sprite collection.

    2> Selected the sprite collection prefab from project and clicked "Open editor" , which shows Option to <Drop Sprites here >.

    3> Then I drop sprites to it . and Nothing Happens !! Does these sprites needs to be of some specific settings ?
    mine are of type texture as shown in Import settings.

    PS: I am using Unity 4.5

    Thanks
     
  5. ThomasVandenberghe

    ThomasVandenberghe

    Joined:
    Feb 28, 2014
    Posts:
    22
    Hi, is it somehow possible on iOS do disable the first capital letter when using an UITextInput item? I'm currently using it for usernames which shouldn't have their first letter capital by default.
    Is it even possible inside Unity?
     
  6. Eklavyaa

    Eklavyaa

    Joined:
    May 4, 2014
    Posts:
    20
    Now I am able create the sprite collection and Animation.

    There seems to be some problem with either unity or 2dToolkit. I took following steps :

    1] From Mac I uninstalled the Unity (by moving the ~/Application/Unity folder to trash ) and deleting the unity preferences found in ~/Library/Prefrences. then reinstalled unity.

    2] Deleted the 2DToolkit package from the "~/Library/Unity/Asset Store" then downloaded it again and imported

    And every thing is fine again

    Thanks!
     
  7. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Sorry I don't know the answer to this, I've not needed it before and not tried it. This simply uses the unity built in input system, so answers.unity3d might have an answer for you.
     
  8. Eklavyaa

    Eklavyaa

    Joined:
    May 4, 2014
    Posts:
    20
    Hi,


    Q1 > I just created 20 levels in scene , by painting the tiles . It consist of coins and bombs and platform. Initially I created a bomb layer in 2Dtoolkit settings and there is a Layer 0 by default . So I added bombs to bomb layer and Coins and Platform to Layer 0. But now I want to create a separate layer for Coins. But I guess I need to repaint all the Coins again by selecting the Coin Layer ? or is there any way I can just change layer by mass selecting coins in a particular Map ?

    Q2 > As all my map will have some default settings , common in all of them . Is there anyway I can create all those tileMap objects with default settings using a script or any other way so that I don't have to create and open each tilemap object and change settings manually. I think it can be done by duplicating a reference tilemap object in which I will put my required settings and just change its name , would it work properly ?
     
  9. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Q1 - Yes thats correct, there isn't any shortcut to this.
    Q2 - No there isn't, but all of this is accessible using an editor script, simply write one to set things up the way you need it and propagate the changes as necessary.
     
  10. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    been using tk2d for a while on iOS, but for latest game, decided to use tk2d camera (instead of unity ortho cam) and anchors to stick sprites to edges of screen for menus and gui. But now when I run on HD device all my gui is tiny... if I don't use tk camera, my gui scales with the screen and looks fine. How can I get tk camera to work this way also so everything is not tiny. Do I have to go through scaling all my gui elements manually for different devices if I use tk2D camera?
     
    Last edited: Jun 27, 2014
  11. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    If you set up a wildcard override with fit height, it'll be have exactly as it did before. You shouldn't have to move or change anything at all.
     
  12. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello unikronsoftware,
    i m using toolkit2d and it s just awesome and simple to use, just love it each day i use it, i use the prefab button, but i need to pass a parameter to send message as i have more than 30 buttons, how i can check witch button is pressed in that case?

    just to be clear, i have 30 buttons, and i want to hide the unselect buttons, when i click on a specific button.

    thanks
     
    Last edited: Jul 6, 2014
  13. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The event parameter can take a tk2dUIItem as a parameter, i.e. it can be OnClick(tk2dUIItem item). You can use that to determine what you've clicked.
     
  14. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    oh i see, but in my case i would need to send an int as parameter to assign an index to an array. i m not sure how to do that with tk2dUiitem.
    any hint would be greatly appreciated.
     
  15. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    it only sends a tk2dUIItem - if you keep a dictionary of tk2dUIItem -> int, you can look it up easy enough.
     
  16. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Is there a an existing way to show the collision normal of the tile maps? Like a gizmo option or something. I can't seem to find it and it seems it should be a given in order to debug issues. I expect the Unity folks to provide it and not necessarily Unikron, but maybe you can point me in the right direction. I'm thinking I will have to write my own stuff to loop through the mesh data and draw the normal myself.

    I seem to be noticing a issue where the tile map sometimes load weird and the collision normal of a specific surface appears inaccurate, but other times when I reload the map, the normal seems fine. If I could see the normal in real time, I can be sure of it.
     
  17. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    I have more information on my issue and may have found a temporary fix using the "Smooth Sphere Collisions" option on the Mesh Collider object because my collision issue was with a Sphere and a Mesh. See pic for info. But I don't really know what's going on still.
     

    Attached Files:

  18. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Thats a bit strange. The easiest way to check normals is to write a script to take the Mesh from the polygon collider and apply it on a normal meshrenderer/meshfilter. If you apply a shader that outputs normals as color, you should be able to figure out whats going on.

    The tilemap mesh isn't regenerated every time you load the level though - its pretty much static, saved when you commit. I dont get how it could change normals when reloading...
     
  19. AR_Rizvi

    AR_Rizvi

    Joined:
    Aug 12, 2013
    Posts:
    40
    Hi
    I have a Question that can i use sprites as my buttons using 2D tool kit if yes then how ? as i am very new to it and still exploring the Plugin so can u plz show the right way
     
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Look at 2D Toolkit UI samples. You can switch collection to your sprites easily, or set up new buttons in the same way.
     
  21. BisongT

    BisongT

    Joined:
    Nov 27, 2013
    Posts:
    9
    Hello,

    I've got a tiny problem. When I use string.Format() on a 2dTextMesh, the resulting string remains unformatted. So for example:

    string myName = "Mr_Recursion";
    myText.text = string.Format("Hi, my name is {0}", myName);
    myText.Commit();

    The resulting display is: "Hi, my name is {0}".

    Anyone with a quick fix?
    Thanks.
     
  22. BisongT

    BisongT

    Joined:
    Nov 27, 2013
    Posts:
    9
    I fixed it. I was overwriting the text with old text somewhere further down the code. It works fine now.
     
  23. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Hi
    I have a UI icon animation in 2D toolkit. The problem I have is that you can see a slight jump in some of the frames of the animation. I've quadruple checked my source art and each png is exactly the same size with the art in each sitting perfectly at bottom. I've tried everything but don't know what to do next to fix this. It's subtle, but it's there, and it shouldn't be as it looks awful. I've tried things like disabling trimming, but that makes no difference.

    I've also tried things like disabling the trimming, but that makes no difference

    Thanks for helping.


    UPDATE:
    I created a very simple (just a circle) animation - the circle is centred in every frame of the sprite sequence. Created a new animation using this circle in middle, and it too jitters.

    2dToolKit, have you tested animations?
     
    Last edited: Aug 1, 2014
  24. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Can anyone help or offer suggestions/ideas? I'm out of them!
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I replied to your 2D Toolkit forum thread asking for a repro case yesterday.

    There is no known issue with animations - that code has been stable for about the past year and a half with lots and lots of people using it daily, so post the repro on the forum / support email and we'll take it from there.
     
  26. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Thanks for your response here and on the other site - I haven't had a chance to visit it yet.

    We've done further tests and have discovered that the issue is an ILLUSTRATOR one. (Thanks Adobe!).

    It seems that if you place each frame of an animation in it's own Artboard and export those art boards, it doesn't export accurately. Even though the art boards are exactly the same size, and the sprite in each in exactly the same position, and the exported file is the same dimensions, the sprite itself may move a pixel or two. The only workaround is to place all sprites on top of each other in the same art board and export one at a time...... It's absolute nonsense. So now we're trying to find out what's up with Adobe *sigh*.....

    Sorry to bother you with it Unikron - really didn't think Illustrator would have this issue.
     
  27. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    For the tk2dCamera, the fit mode overrides, there doesn't appear to be a way to set the X, Y values by a 0.0 - 1.0 percentage. It seems to take resolution coordinates only. The reason why this is a issue for me is say I have 2 different 3:2 ratio devices with far different resolutions. I need to adjust the camera for the 3:2 ratio, but if I can only move the camera down by resolution coordinates, then can only work for one 3:2 ratio device. I rather specify a 0.0 - 1.0 percentage of the 3:2 ratio or something, so it works on both devices.

    Are my assumptions correct? Because my solution would be to just write code on top of the fit mode to get what I need.
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    For more advanced setup, you can set up the overrides dynamically - simply set up one wildcard override and then modify the settings as you wish on it from a script. The override itself is accesible from code so you dont need to modify tk2d code to achieve this.
     
  29. Sam-K

    Sam-K

    Joined:
    Mar 23, 2013
    Posts:
    27
    hi, I want to create and load images dynamically . Im fetching my data from AssetBundle.
    Whats the proper way of creating SpriteFromTexture dynamically ( 1- Create Gameobject and AddComopnents, 2- Prefabs, 3-Some builitin tk2d way 4 or any other ). and how to load images into it dynamically.
     
  30. unikronsoftware

    unikronsoftware

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

    Check the runtime sprite collections sample - it shows a few ways of creating sprites at runtime. One option is to load texture packer atlases, another is to simply create one or more sprites from a texture.
     
  31. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    Hi,

    I have a problem that is probably easy to fix, I just can't find it. I'm using the TileMap, and all images and sprite collections are set to a filter mode of Point. The sprite collection's padding is set to "Extend".

    When I run the game within Unity, things work fine. But when I build and run it, I am getting gaps between all of the tiles.

    Any ideas?
     
  32. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Add one pixel of padding to the sprite collection, should help.
     
  33. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    Worked perfect, thank you!
     
  34. Sam-K

    Sam-K

    Joined:
    Mar 23, 2013
    Posts:
    27
    Hi,
    I have a few questions. Some of these may be beginner questions but it would be a lot of help if you answer.
    Im going to make a card game for mobile. The view will be like clash of clans.
    • The Map Can Expand
    • The view will be iosmetric as mentioned earlier
    • Everything will be retrived and send to the server eg. position of tiles ,buildings, level etc etc
    • The game which im going to make is done in IOS Cocos2d. Those guys havent used any tilemap library. They have written theri own iso lib. I saw the tilemap tutorial its for level making and tilemaping. But what i want to do is make the map dynamically.
    • Considering my requirement should i use tilemaps and would it be sufficent, ofcouse for the part it does. and What does ISO tiles do. Tile type ISO.
    • And now that unity has provided the sorting layers and depth. What should one use the tilemap layers or the Unity sorting layers.
    • Im using asset bundles download content and create sprites from them very rare but do when some changes occur. What if a new hero comes or a building. because Tilemap uses spritesheets. I would have to pack the bundle with a sprite sheet and replace the existing one with it . any issues you see here

    I loved the tilemaps i think it can be used in my situation. Kindly reply to these questions.
    Sam
     
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Please dont cross post, I've replied on the tk2d forums.
     
  36. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    Hi,

    This is not a technical question, sorry.

    Do you plan on supporting Unity 5, when it ships?
    I'm asking because I don't really like the direction in which the native 2d stuff is going, and it doesn't look like it's going to improve anytime soon.
    I'm also asking because I've been working in a project for a year or so, and it's likely that I'll need at least another year, and I wouldn't want to get stuck with an outdated version of unity.

    Support has been superb on your side in the past so I've no reason to think that this might change, but we all have to make hard business decisions sometimes.
     
  37. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    We plan to support it for as long as it is financially viable. We'll definitely get it to work with 5.0 at least (it already does in the beta with a few small changes).
     
  38. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    ok, let's hope it remains financially viable for a looong time!
     
  39. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    This is just a general query asking for a few pointers to set up some animations. I've messed about with a variety of the anchor settings and Global or local tabs but I'm basically getting jittery character animations. I've been using Sprite Maker to capture 3D character animations as 2D sprites. Unfortunately it doesn't build a spritesheet but simply renders out individual sprites. This causes the animations to jump all over the screen so I used photoshop to resize the canvas. However, with the atlasing this is getting trimmed off and the sprites still jitter. So I switched off trimming but with no result. I assume that the sprite atlases rebuild so I'm wondering whether I am doing something wrong. More than likely it is more to do with how the images were captured so before I bother to rewrite soem of the sprite amker code to make a spritesheet I was wondering whether you had encountered this previously and could give a quick solution in terms of what checkboxes should I be switching on, how should I set the anchor, should the game object pivot be centred and set in local space?

    Any help is greatly appreciated.
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I'm not sure really, if your images don't line up I dont think your animations are going to be too great. If you switch off trimming, tk2d doesn't really do anything much there - you will need to correct your source images so they are correctly line up and dont jump about in there....
     
  41. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    Yes, I guessed that.It was really just a longshot. I've managed to figure out a couple of work arounds that should do the job.
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  43. Brumby

    Brumby

    Joined:
    Sep 8, 2014
    Posts:
    16
    Hi,
    I'm trying to animate the scale of Tk2dSprite using Unity Animation. In the Inspector (while play button is pressed) scale value of Tk2dSprite is changing but it looks like Sprite remains the same on the Scene. Is there any solution for that issue?
     
  44. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    There is a workaround but not a particularly efficient one (look for Animation Adaptor on the tk2d forums). Unity animation sadly doesn't animate c# properties, only member variables - detecting change is expensive.
     
  45. Brumby

    Brumby

    Joined:
    Sep 8, 2014
    Posts:
    16
    What a pity! It would be very convenient solution for 2d animation.
    Thanks for your quick reply.
     
  46. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    For the tk2dUIItem class, I'm interested in a Hover like event when sliding your fingers on a touch device over a collider. Currently I don't see any input events that fit my needs, and the current hover events are commented as only working with the mouse. What I am trying to achieve is a DPad control implementation and I want the user to be able to press anywhere on the DPad, and be able to slide their thumb in any of the 4 directions and enter and exit 4 colliders without lifting a finger. Is this possible to do easily or will I have to roll my own code for this particular input?
     
  47. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You'll have to roll your own solution for that. That has been in the todo for a while, but I don't know of a timeframe, or indeed if ever it will get done.
     
  48. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I too have a problem I can't seem to solve with 2dtk buttons. I have a left button, right button and fire button on screen. I want the player to be able to move left and right and fire at the same time. its a Mobile game and OSX so needs to work on both. Currently if the player has a button like LEFT held down, as soon as he presses fire, the LEFT button gets released! I need to be able to press 2 buttons at once and know they are still pressed. Any ideas how to do it in 2dTK?
     
  49. Mr_Cad

    Mr_Cad

    Joined:
    Dec 7, 2013
    Posts:
    27
    I was looking the best way to render a sprite which doesnt packed into a sprite collection. Which way should I use?
    I try to use Sprite from Texture but I noticed whenever I change the texture during runtime it might cause some unwanted lag. Any suggestions for me?
    What's the best way of changing the texture during runtime?
     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Turn on Use multi touch in the tk2dUI Manager script. That should fix it