Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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

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

  1. janoonk

    janoonk

    Joined:
    Dec 3, 2008
    Posts:
    79
  2. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The most up to date tutorials and docs are the written walkthroughs here:
    http://unikronsoftware.com/2dtoolkit/doc/

    The software is constantly being updated. We're on version 1.90 now, and on each major version we have added huge changes to the core system and/or interface. I'll be creating a new video tutorial after 1.90 is done. With audio this time around. Hopefully the interface doesn't change too much, as video tutorials tend to take a lot longer to produce and update.

    ps. Check the "Preparing a font" section of the docs to find out how to use fonts.
     
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  4. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Sorry for deleting the post, just saw your answer right now. Thank you.

    Keep it up with all this good work!
     
  5. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Just reuploaded. Offline docs should work fine now.
     
  6. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    I'm pretty sure you thought about that already and there is a reason why it is not implemented, but I'd like to know if I can keep my hopes up for this kind of feature:

    You have a huge background image which is almost totally opaque, but the edges which are irregular, what I do now, is cut out the edges and place them as separate sprites in the editor, so I can have a solid shader for the opaque piece and little bands of alpha shaders on the edges. It would be cool to have something automated like an intelligent dicing.

    Now I know my situation could be particular because the depth sorting of my background is simple so I don't have to worry about this and if you do something automated you would want this to work tidy clean without risking to double the number of draw calls and all that, this is why I'd like to know if it could be possible anywhere in the next 10 years?
     
  7. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Well, not quite automated but you could do this - export 2 textures from the original, the same size - one being the solid bit, and the other just the transparent bits with a totally transparent part where the solid bit used to be. Dice this one, and perhaps the solid one too, and apply 2 different materials to it in the sprite collection editor. Create 2 sprites at the same position, make one a child of the other = done.

    Thing is, it isn't too bad to implement something like this. However, your use case is a very specific one and ideally something like this would have to work with a majority of cases rather than something very specific, like a rectangular image. In most cases too, it is probably far more optimal to build a very tight edge cage rather than simply dicing as usual.

    I'll think about it further now that you've brought it up again. Some new ideas might spring to mind.
     
  8. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    Maybe some sort of "intelligent dicing" in addition to the other render mesh modes, this mode creates sections of opaque textures and sections of alpha textures, detecting the intersections of the bounds of alpha = 0 and bounds of alpha !=0 (could be a challenge as some images could be very irregular and would need several sets of bounds, you'd need a precision treshold too in order to not have a ton of 1 px subdivisions for circle-like images), another problem would be the need of two different atlases and the draw call issues, I think.

    An easier way would be to use the current dicing as a base and just put an opaque shader on fully opaque images, the second problem I mentioned still applies though.

    Well, I know that may be a bit more complicated than that, it always is, but I hope my innocent and simplistic view of the thing could trigger an idea in your mind.
     
  9. afarmer

    afarmer

    Joined:
    Jan 17, 2013
    Posts:
    12
    Hello.

    Thanks for your feedback on the animated sprite question. I'll let you know if it happens again, with more steps to reproduce if it does.

    With regard to cached/generated data, should team members exclude the "-tk2d.asset" file from SVN? It sure changes a lot, and if it's generated I'm guessing it could even be harmful to merge it?

    Thanks,
    afarmer
     
  10. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You should exclude -tk2d.asset from SVN. Best practice - rebuild the index every time you merge assets. The file contains an index of all tk2d related assets present in your project.
     
  11. afarmer

    afarmer

    Joined:
    Jan 17, 2013
    Posts:
    12
    How do I rebuild it? Just delete it?
     
  12. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    "2D Toolkit > Rebuild Index" menu item.
     
  13. afarmer

    afarmer

    Joined:
    Jan 17, 2013
    Posts:
    12
    Great, thanks!
     
  14. Mikael-Madrid

    Mikael-Madrid

    Joined:
    Nov 2, 2012
    Posts:
    26
    Hey everyone,just started using 2dtk,props to the creators! :p anyways,Im having a little issue,our main character is made in pixelart(if that matters) and when I import it and put in the scene there is a "white line" of pixels in some areas around him,any solution to this? maybe doing a manual trim?,thanks in advanced.
     
  15. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi Mikael,
    Please email a screenshot of this to support at unikronsoftware.com. I think I may know what it is, but its hard to tell without actually seeing it.
     
  16. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    Hi there, sorry to bother you again, but is there some way to make a class that takes all the common properties (scale and color) of BaseSprite and TextMesh and put them in an Interface which would be implemented by both? The feature would allow for much cleaner code when not knowing which one will be accessed but you know one of them will be accessed.
     
  17. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You could do it, though I don't really see a major benefit from it, as they would just be those two properties - the textMesh can have 2 color properties for gradients - changing one will affect the other, and not it in a good way. You can use the animation editor to do this. Code here, save it as tk2dAnimationAdapter.cs in your project:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. [ExecuteInEditMode]
    6. public class tk2dAnimationAdapter : MonoBehaviour {
    7.  
    8.     public Color color = Color.white;
    9.     public Vector3 scale = Vector3.one;
    10.     tk2dBaseSprite sprite = null;
    11.     tk2dTextMesh textMesh = null;
    12.  
    13.     // Use this for initialization
    14.     void Start() {
    15.         sprite = GetComponent<tk2dBaseSprite>();
    16.         textMesh = GetComponent<tk2dTextMesh>();
    17.         if (sprite != null)
    18.             color = sprite.color;
    19.         if (textMesh != null)
    20.             color = textMesh.color;
    21.     }
    22.    
    23.     // Update is called once per frame
    24.     void Update () {
    25.         DoUpdate();
    26.     }
    27.  
    28.     void DoUpdate() {
    29.         if (sprite != null  (sprite.color != color || sprite.scale != scale)) {
    30.             sprite.color = color;
    31.             sprite.scale = scale;
    32.         }
    33.         if (textMesh != null  (textMesh.color != color || textMesh.scale != scale)) {
    34.             if (textMesh.color != color) textMesh.color = color;
    35.             if (textMesh.scale != scale) textMesh.scale = scale;
    36.             textMesh.Commit();
    37.         }
    38.     }
    39. }
    40.  
    41.  
     
  18. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    Thanks for your care, seriously going all the way to even make a whole (simple) class for a stranger, that's cool. But I already made this kind of script, I just feel it could be much cleaner and more optimized if I did not have to verify and store both datas, I know this kind of feature is not so exciting, but if you ever happen to make an auto-commit system on TextMeshes, it shouldn't be too hard to do, I'm just pointing one way to maybe "improve" your already astonishing piece of software.

    Here is the script I use right now for a frame by frame animation converter from flash, this is the reading part. Maybe you can understand better my request, considering I could have up to 60 items using this script on the screen on an iPhone.
    Code (csharp):
    1.  
    2.  
    3.        //FrameInTransform (FIT) has sprite (tk2dBaseSprite) spriteT (tk2dTextMesh) sprites (tk2dBaseSprite[]) spriteTs (tk2dTextMesh[])
    4.        void readFrame(FrameInTransform[] frame ) {
    5.         foreach(FrameInTransform data in frame){
    6.                        
    7.             //if there is position data to be taken from FIT, change position
    8.             if (data.posAffected) {
    9.                 data.trans.localPosition = data.pos;
    10.             }
    11.  
    12.             //if there is scale data to be taken from FIT, change scale
    13.             if (data.scaleAffected) {
    14.                 if (data.sprite!=null) {
    15.                     data.sprite.scale = data.scale;
    16.                 } else if (data.spriteT!= null) {
    17.                     data.spriteT.scale = data.scale;
    18.                     data.spriteT.Commit();
    19.                 } else {
    20.                     data.trans.localScale = data.scale;
    21.                 }
    22.             }
    23.  
    24.             //if there is rotation data to be taken from FIT, change rotation
    25.             if (data.rotationAffected) {
    26.                 data.trans.localRotation = data.rotation;
    27.             }
    28.  
    29.             //if there is color data to be taken from FIT, change color
    30.             if (data.colorAffected) {
    31.                 if (data.sprite != null) {
    32.                     data.sprite.color = data.color;
    33.                 } else if (data.spriteT != null) {
    34.                     data.spriteT.color = data.color;
    35.                     data.spriteT.Commit();
    36.                 } else {
    37.                     if (data.sprites != null) {
    38.                         int j = data.sprites.Length;
    39.                         while (j-- > 0) {
    40.                             data.sprites[j].color = data.color;
    41.                         }
    42.                     }
    43.                     if (data.spriteTs != null) {
    44.                         int j = data.spriteTs.Length;
    45.                         while (j-- > 0) {
    46.                             data.spriteTs[j].color = data.color;
    47.                             data.spriteTs[j].Commit();
    48.                         }
    49.                     }
    50.                 }
    51.             }
    52.         }
    53.     }
    54.  
    Oh and maybe a requests section on your forums ;)
     
  19. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Don't think that is possible to do PROPERLY without breaking backwards compatibility, and also putting it in an interface will make it virtual :( I'll keep it in mind for when I redesign the interface, though - hopefully sooner rather than later.

    About a requests section - I'll have to think about it a bit. Dont' wanna get swamped with requests!
     
  20. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Someone on a team I'm on bought a 2D Toolkit license, and I'm playing around with it at the moment and looking at the code. We need to use a palletizing system; storing RGB for all of the sprite pixels is too much unnecessary data. Instead, I want to pack multiple atlases into the same texture, using each channel as a lookup into a 24-bit color palette. Do you think there's any way to combine that with 2D toolkit, without having to fork your code? From what I'm seeing so far, it seems like your system really wants to use its own simple materials.
     
  21. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You can change the prebuilt materials as soon as you've created the sprite collection, just find the material in the inspector and change it as you like. The main issue you're likely to run into is that the trimming will probably throw away useful data in the r,g,b channels - you can "Disable Trimming" in sprite collection settings.

    You could use the vertex colors to select between the sprite data in the RGBA channel - should be quite efficient, but the dependent texture read for the palette will cost you. One more thing to note - the frame animation system doesn't animate colors, so if you're intending on building an animation out of this you'll have to animate that property manually.
     
  22. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Depends on where you want efficiency. It's better to select a channel using four different shaders than to do a dot operation (and indexing a color based on a variable is way slower than either). You don't get batching between the different channels of course, but I think that's fine, given the reduction in shader instructions...

    ...Profiled. I'm assuming the giant reduction in texture data saves the day.

    I'm still working on figuring out what to do; at this point, I'm leaning towards the idea that we can do everything without modifying your code, except for the sprite preview you put in the Inspector. It would be nice if you could use your own material for tk2dSpriteThumbnailCache.DrawSpriteTexture, because the packed textures I'm talking about aren't easy to look at.
     
  23. unikronsoftware

    unikronsoftware

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

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The issue with DrawSpriteTexture is that it clips in the shader, no real way to use custom shaders - unless of course some metadata is stored somewhere to look up a corresponding preview shader. You might have to hack this in for now...
     
    Last edited: Jan 27, 2013
  25. SSnowman

    SSnowman

    Joined:
    Nov 15, 2012
    Posts:
    8
    I've discovered a weird bug you might want to take a look at:

    I wrote a collision detection system utilizing rays. It appears that forward rays will for some reason snag on a ground tile if the ground tile is at the edge of a chunk in the tilemap. I've attached a screenshot to show you what I mean. The selected item is a tilemap chunk. As you can see the character has stopped moving forward at the edge of the chunk. This happens at all chunk edges.



    Of course, this can be solved by having a ray that's a little higher than the ground, but then you possibly lose some precision in the collision check.
     
  26. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This seems to be an issue with physics in Unity - I have managed to reproduce this with 2 box colliders laying aligned perfectly horizontally, so it isn't isolated to just the mesh collider the tilemap system generates. I haven't investigated further to work out what it could be, how to solve it, etc, Has anyone else seen anything like this?
     
  27. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    I apologise if this has been answered, but are you continuing to support 3.x?

    It appears that EX2D has stopped supporting 3.x versions, so I'm keen to stick with something that won't leave me high and dry.

    Thanks
     
  28. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Our primary dev platform is still 3.x and we'll continue to support 3.x for as long as Unity doesn't break backwards compatibility in a way that makes it impractical / hard to support both - though the plan is to limit it to 3.57 starting in the next few releases.
     
  29. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Thanks, that's great news. Does this also mean that the 2.0 overhaul you've been talking about will be fully compatible with 3.x?
     
  30. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Yup, thats the plan. By 3.x it'll be 3.57 specifically, though. I do plan on removing some of the backwards compatibility stuff for 3.0-3.49 at some point...
     
  31. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Again, great news, I really appreciate it.
     
  32. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    Hello!

    In many tutorials I've read that it is nice to keep a proportion between Unity3d's environment measurement-units (I'll call those un to avoid confusion) and real world measurement units (such as meters). For instance, as in:

    I would like to know if using tk2d camera and its 1 pixel == 1 un is alright regarding the collisions scheme employed by Unity3d, I've read in really several cases that this would be a would approach regarding physics, but if 1px = un, the 1px would surely in almost all cases mean a lot less than 1 meter, lets say.


    Do I have reason to be worried and are there any precautions I should take on 1px = 1un approaches?


    Thanks in advance.
     
  33. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The article is right having to change gravity and other physics parameters to accommodate. There isn't a great deal that goes wrong when you do that though, and you will only go through the pain of setting it all up for your game once.

    There aren't any magic numbers that "work", as they depend very much on the size of your sprites and what they represent.
     
  34. Code_Helix

    Code_Helix

    Joined:
    Feb 21, 2012
    Posts:
    79
    Is there any plans to release some kind of Lite version or a Trial version? I really want to try this out but can't gamble away my money if for some reason I can't use it or get a hang of it. Not saying that it's a bad product just wish there was a way to take it for a test drive so that way I will feel more comfortable making the purchase. Also I'm working with a friend on a project so will we both be able to use it with one purchase or will he need to purchase it too? If its the later then I will have to wait til he's able to purchase it.
     
    Last edited: Feb 10, 2013
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    We don't have a trial version at the moment - the product is distributed as full source, and that makes it hard to make a trial for obvious reasons... However, drop me an email (support@unikronsoftware.com) and I'll see what I can do about a limited trial or something.
     
  36. Squarefish

    Squarefish

    Joined:
    Mar 15, 2012
    Posts:
    5
    Hi, Unikron Software.

    I just would like to endorse your product in this thread. I struck upon your 2dtoolkit recently and it's been well worth the investment!

    It's a definite time saver... perfect add on for any 2d platform game... I imagine it's also very worthy for other types of 2d games. I don't think I've really cursed anything in the 2dToolkit, it encourages a very practical game development approach.

    Got my game environment set-up in a couple of days (having some prototype graphics)... still finding it easy to work with... or really much, "alongside" ;-)

    2dtoolkit + Unity isn't quite a games studio I'm sorry to say, but anyone familiar with Unity3d would find this indispensable for 2d game development. A toolkit... exactly what it says!

    Thanks for putting a great script reference. I can see user support is second to none, I've found some tips helpful.

    Great product.
     
  37. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Thanks for the kind words :)
     
  38. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  39. Noktai

    Noktai

    Joined:
    Feb 11, 2013
    Posts:
    40
    Is there any way to create a tilemap dynamically through a script? As of now, I can only setTiles like this:

    Code (csharp):
    1.  
    2. tk2dTileMap tilemap = GameObject.Find("TileMap").GetComponent<tk2dTileMap>();
    3. //TileMapUtility.ResizeTileMap(tilemap, 100, 100, 25, 25); //no accesable in scripts :(
    4. tilemap.Layers[0].SetTile(0, 0, 40);
    resizing or creating a tilemap from scratch doesn't seem possible.
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It isn't supported for various reasons - mainly to do with the complexity of repartitioning, but the code could be modified to do it if really required. However...

    You can create a tilemap as large as you'd ever want, the system partitions everything - it won't store any data for partitions without actual tile data, so if you create a large empty tilemap, the overhead is minimal. As you SetTile and populate the tilemap, it will start creating the data for partitions. Don't forget to call tilemap.Build() after you're done Setting tiles.

    I'll keep in mind an API to create a tilemap from script dynamically.
     
  41. Eagan

    Eagan

    Joined:
    Feb 13, 2013
    Posts:
    1
    Hello 2D Toolkit / Unikron Team,

    I'm afraid I sent this via email before seeing your request to use the forums for product questions - sorry!

    I'm a hobbyist developer and I'm pricing out 2d frameworks to implement a Unity/Mobile game with pals (just for fun). Your framework looks amazing on all counts (and affordable for someone like me!). It looks like really exceptional work, and I can't wait to try it.

    One tool we're looking for is a tilemap editor for Unity that supports tilemap animations (on weaker mobile platforms). I can't tell from your docs if this is reasonable, or if it's something you feel a competent developer could add based on your objects?

    (e.g. We want all of the tiles to animate a little, we did this using game objects during GGJ13, which of course will not-at-all run on mobile. Here's a visual if that helps: http://www.youtube.com/watch?v=G0dC-71Cgb8).

    Replying with a simple "Yup, it can do that" or "Nope" would be fine (I know you're busy!), and I am of course incredibly grateful for your time.

    Thanks very much!
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I've replied to your email :)
     
  43. bigcheese_

    bigcheese_

    Joined:
    Sep 6, 2011
    Posts:
    31
    Hello, I've been using 2d Toolkit for a while now, but I'm facing some weird issues lately, here are 2 of them.

    -For a character animation sequence, when the atlas is at max size 4096, the quality of the sprite is low and it's pixelated, but id I remove some of the images from the sequance to make it fit in a 2048, the quality is back to perfect. What could be causing this issue? This way I have to either use more Collections or multiple atlases.

    -The second issue I faced was with packing a couple of backgrounds to an atlas, the atlas was by default of size 2048X4096 but when I build it and try it on a various Android devices, the sprite show as black. However when I used Force Square, making the atlas size of 4096X4096, it all worked properly, what could be casing this issue?

    Regards,
    Thanks
     
  44. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    This is likely because the maximum texture size is set up somewhere. Can you select your atlas texture and look at the MaxSize parameter - perhaps thats set to 2048? Also check the android specific override, it could be platform specific.

    Some android devices don't support non-square textures, especially when compressed. Same thing happens if you try to use non-square PVRTC compressed textures on iOS. Check your formats, and try 16bit / uncompressed if you arent using that already.
     
  45. bigcheese_

    bigcheese_

    Joined:
    Sep 6, 2011
    Posts:
    31
    The max size is set to 4096, and no overrides what so ever, and the pixilizaion happens in the editor, it's really weird, haven't seen that before ever.


    Maybe, but the textures had no compression what so ever, but perhaps it's from the device it self.
     
  46. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Thats really bizarre, not seen it before. Something MUST be changing it somewhere in Unity, especially if it happens in the Editor too.

    To confirm that its the device, I suggest creating a 4096x2048 texture in photoshop and applying it to a cube or something. If its black on device, it pretty much will confirm it.
     
  47. bigcheese_

    bigcheese_

    Joined:
    Sep 6, 2011
    Posts:
    31
    The thing is, the atlas info still show as RGBA 32 bit 2048X4096, with the sprites pixelated.

    I can confirm that I've tried switching the platform to standalone in the project settings, and the issue disappeared, please not that all these issues are happening in the editor it self. I made sure there isn't any kind of override compression happening anywhere.
     
  48. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Sounds very much like a device issue... Might be worth sending a repro case to Unity support in case its a bug.
     
  49. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,771
    Hi guys,

    Hey 2DToolkit is an amazing addon! Such a time saver!

    I'm just having a little trouble accessing it through scripting though. I noticed that there's a C example in the documents, just wondering how can I access it through unityscript?

    Thanks
    Pete
     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The only thing you need to do to access it from JS is to run the "2D Toolkit > Setup for JavaScript" menu item. That will move the scripts into appropriate directories so it works properly with JS. You can then use the classes directly as you would any other:

    Code (csharp):
    1. var sprite : tk2dSprite;
    2. sprite = GetComponent( tk2dSprite );
    3.  
    4. sprite.color = Color.red;
    and so on...