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
  2. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    Hey, me again.

    Can a material be used to replace an image on the Tile Map? For example, you can chop down bushes. Or open doors.

    Or is it better to use sprites? I saw a tutorial that turned tiles into sprites using prefabs I think it was.
     
    Last edited: Jan 29, 2014
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Its easier to use sprites that are turned into prefabs, then attach any behaviour you like to the prefab.
     
  4. x0adam0x

    x0adam0x

    Joined:
    May 4, 2013
    Posts:
    9
    Hey all, Just running into an issue with playmaker and 2DTK if anyone can assist.

    Essentially I'm trying to make my 2D Sprite jump, I've attached a 2D Rigid Body have made an FSM in Play Maker to add force
    to the sprite when a button is pushed.

    The issue is that there is an error saying that you can only add force to something with a rigid body, it's not detecting the 2D rigid body so what would be the alternative?
     
  5. unikronsoftware

    unikronsoftware

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

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    hi Unikron,

    I'm using the bounds returned by the box collider in an animated sprite to do some collision stuff.
    However, I've noticed that tk2dSpriteAnimator updates the box collider bounds on LateUpdate().

    Because my script needs the updated collision bounds to work properly, it needs to run after tk2dSpriteAnimator, which means moving a bunch of my scripts to run during LateUpdate.

    My question is, is there a particular reason for tk2dSpriteAnimator to run during LateUpdate()?

    I've modififed tk2dSpriteAnimator to make it run during Update() and it seems to work just fine.

    I don't know why you put it in LateUpdate but if it turns out that tk2dSpriteAnimator doesn't need to run during LateUpdate, you might want to consider moving it back to Update() at some point. Just saying.

    Thanks.
    Nacho.
     
    Last edited: Feb 1, 2014
  7. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    So this may be a Noob Question, But I am importing someone else's sprite sheets and for the most part it is smooth going. But occasional I see a frame that needs to be shifted a few pixels. Is there an easy way to do this in 2D Toolkit?
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Its in LateUpdate to handle the cases where you change an animation during Update and expect it to change by the end of the frame, eg. when triggered by a collision. Its just convention I guess, you can pick anything you like here. It would be impossible to change behaviour of something like this due to backwards compatibility - it would change all existing projects in subtle ways, but thankfully its a small change that is easily maintained if you wish, you can also inherit from the class like tk2dUISpriteAnimator does (also be sure to make an equivalent tk2dUISpriteAnimatorEditor) - this will survive upgrades too.
     
  9. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    No there isn't, we've never really needed that. If you fancy modifying the tk2d code, it should be fairly trivial to add - feel free to post on the tk2d forum if you'd like some help with that. Having said that there have been a few requests for this very thing recently - I'm considering putting it in as a feature.
     
  10. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    It comes in handy. For example I was importing Butterflies. Their movement is erratic, so tweaking becomes necessary.
     
  11. nachobeard

    nachobeard

    Joined:
    May 7, 2013
    Posts:
    47
    thanks, didn't think about inheriting from spriteanimator, really good idea.
    nacho.
     
  12. BranDino

    BranDino

    Joined:
    Apr 12, 2013
    Posts:
    16
    not sure if this helps but sometimes I have to adjust the custom anchor point in the 2d sprite collection per each affected sprite to get them to line up correctly in sprite animation clip especially if animated object in the sprtie changes size positions from frame to frame

    Posted: 03:01 PM 1 Week Ago
    Quote Originally Posted by SoloChristian View Post
    So this may be a Noob Question, But I am importing someone else's sprite sheets and for the most part it is smooth going. But occasional I see a frame that needs to be shifted a few pixels. Is there an easy way to do this in 2D Toolkit?
     
  13. gavku

    gavku

    Joined:
    May 21, 2013
    Posts:
    2
  14. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    No there isn't a demo as its distributed as full source code. Email support at unikronsoftware.com and I'll see what can be done.
     
  15. gavku

    gavku

    Joined:
    May 21, 2013
    Posts:
    2
    Cheers for the reply. We have actually grabbed a license and it seems to do everything we want it to so far ;)
     
  16. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    I keep on getting the following errors when importing the toolkit:
    Assets/TK2DROOT/tk2dUI/Code/Controls/tk2dUIDropDownMenu.cs(60,25): error CS0433: The imported type `System.Action' is defined multiple times
    Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteAnimator.cs(105,23): error CS0433: The imported type `System.Action`3' is defined multiple times
    Assets/TK2DROOT/tk2dUI/Code/Controls/tk2dUIDropDownMenu.cs(60,25): error CS0433: The imported type `System.Action' is defined multiple times

    Have you got any idea what could be causing this? To me it looks like a conflict with some other plugin which is pretty much the normal run of things with Unity. I was wondering whether you have any clue what type of plugin it is conflicting with? Assuming you haven't seen this before and know what has to be done. Is it likely to be conflicting with a GUI system such as NGUI?
     
  17. Dan_Tsukasa

    Dan_Tsukasa

    Joined:
    Jan 26, 2013
    Posts:
    155
    Does anyone know if its possible to turn of the crosshair/grid markers in the animation window? Trying to record animations from there is a bummer when theres the crosshairs lurking behind.
     
  18. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    System.Action is a standard .net library class. What other plugins have you got in the project?
     
  19. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Awesome! Thanks for getting it. If you run into any issues / have any specific questions - we have a dedicated support forum here.
    http://2dtoolkit.com/forum/index.php
     
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    tk2dSpriteAnimationPreview
    The axis grid draw should be pretty obvious in there. Just delete the ones you don't want
     
  21. Closet-Ninja

    Closet-Ninja

    Joined:
    Feb 20, 2014
    Posts:
    2
    I guess this is where to drop feature requests.
    As an animator, it would be great if you could add a few more of the TK2d component features to the animation window. The big ones I'd like to see are "order in layer", "sprite" and maybe even "collection". Not sure if these have already been requested or are on your radar already but these would be fantastic additions.
     
  22. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    I managed to solve the issue. Thanks.
     
  23. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Which animation window is this? Its probably better to ask for feature requests on the official forum so it doesn't get lost in the thread (www.2dtoolkit.com/forum)
     
  24. Closet-Ninja

    Closet-Ninja

    Joined:
    Feb 20, 2014
    Posts:
    2
    The "animation window" in question I guess is better described as Unity's animation 'Panel', my mistake. Pretty much I was hoping to get those options added to the "Add Curve" dropdown in that panel. I know sprites can be swapped via code, but that isn't helpful during the animation process. The "order in layer" property would be fantastic since layering on the z-axis will screw up once you flip the character (for example).
    Anyway, I'll compile all of this over in your forum once I figure out which subforum best suits a feature request.
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I should mention that its not really possible to add a great deal to the unity animation window. You can't animate c# properties yet, and that really limits what you can do there.
     
  26. tu-haq

    tu-haq

    Joined:
    Jul 6, 2012
    Posts:
    10
    I can not go to website http://www.unikronsoftware.com/ ?
     
  27. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Are you from Vietnam by any chance? I've heard a few reports that the website is blocked inside Vietnam, no idea why or how to fix it though. It apparently works if you use a US proxy. Let me know and I'll investigate further.
     
  28. duffyrobert47

    duffyrobert47

    Joined:
    Feb 26, 2014
    Posts:
    6
    Hi, i bought ur plugin and used for couple month, today i notice that some time when i call Resources.Load to load tk2d prefab, it will drop my framerate down, so i do a simple test, and use profiler to check, i see somethings wrong when unity load tk2d prefab(No texture assign to prefab, only sprite collection), plz see screen shoot, it take too much time to instantiate a simple prefab. plz double check it again (my guess is i have a lot of sprite collection)

    $Screen Shot 2014-02-26 at 11.33.12 AM.png

    $Screen Shot 2014-02-26 at 11.56.22 AM.png
     
  29. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The textures are linked in the sprite collection. If your atlases are large it WILL get loaded in. When Resources.Loading a prefab you'll be instantiating all dependent data - if you link to 5 sprite collections in your animation which is linked to your prefab, all of them will get loaded in turn, and they contain references to textures and materials internally. I don't know how big your data is so I can't really give you any specific advice here.
     
  30. Tyrathect

    Tyrathect

    Joined:
    Jul 10, 2012
    Posts:
    38
    Hey guys, love your code.

    Can I ask you to make a small change? Right now you support multi-channel packed fonts imported from BmFont, but the code that manages the material doesn't put in the right shader.

    Could you please change the following code in your next release:

    tk2dFontEditor.cs: The GetShader function is currently:

    Code (csharp):
    1.     public Shader GetShader(bool gradient)
    2.     {
    3.         if (gradient) return Shader.Find("tk2d/Blend2TexVertexColor");
    4.         else return Shader.Find("tk2d/BlendVertexColor");
    5.     }
    6.  
    but should be:

    Code (csharp):
    1.     public Shader GetShader(bool gradient, bool packedFont = false)
    2.     {
    3.         if (packedFont)
    4.             return Shader.Find("tk2d/Goodies/PackedTextMesh");
    5.         else if (gradient)
    6.             return Shader.Find("tk2d/Blend2TexVertexColor");
    7.         else
    8.             return Shader.Find("tk2d/BlendVertexColor");
    9.     }
    10.  
    The function is called in two places in that same file. The first is when no material is assiged to the font.

    it is currently (around line 85):

    Code (csharp):
    1.     gen.material = new Material(GetShader(gen.gradientTexture != null));
    but should now be:

    Code (csharp):
    1.     gen.material = new Material(GetShader(gen.gradientTexture != null, gen.data != null  gen.data.isPacked));
    The second call is when there is already a material, it checks make sure it's got the right one. That line is currently (around line 110):

    Code (csharp):
    1.     Shader s = GetShader(gen.gradientTexture != null);
    but should now be:

    Code (csharp):
    1.     Shader s = GetShader(gen.gradientTexture != null, gen.data.isPacked);
    This would solve a lot of headaches when trying to use multi-channel fonts.

    Thanks a lot!
     
    Last edited: Mar 6, 2014
  31. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hey thanks for the contrib - I'll add it to the next release.
    That feature never got any more love as it was an experimental feature and I didn't know of anyone that used it. Glad to hear someones actually using it :)
     
  32. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,125
    Hello! I've just discovered that tk2d is causing a weird error when on on Windows 8 (Windows Store Apps, but I tried web player and same thing)




    Right, I've just yesterday installed Windows 8.1 and the latest Unity 4.3.4f1

    I am trying to build a game that was previously published for the Mac (Standalone) - however, when I downloaded my project via the asset server I get this error:

    Code (csharp):
    1. Internal compiler error. See the console log for more information. output was:
    There is no message after that. I opened the editor log and there it says:

    Code (csharp):
    1.  
    2.  
    3. - Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
    4. Internal compiler error. See the console log for more information. output was:
    5.  
    6. (Filename:  Line: 0)
    Double clicking the error doesn't do anything either


    I discovered it was tk2d by randomly deleting folders out of desperation - deleting tk2d made the error go away.
    To confirm, I've created a new project and added tk2d (tk2d.18.09.v2.2final) and the error appeared

    is this fixed in the new tk2d? should I update it? thanks in advance!
     
  33. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You should probably update and test the latest version.
     
  34. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,125
    Okey, I've created a new empty project and imported the latest 2d toolkit from the asset store( 2d toolkit 2.3.3),
    still getting the same error as above- using Unity3D 4.3.4f1 (30 day pro trial license), Windows 8.1
    The error occurs for all platforms that I've tested (standalone, web player, Windows store apps)
     
  35. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    You're getting the internal compiler error on WebPlayer and standalone?
     
  36. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,125
    yes - it appears in all the platforms that I've tried: standalone, web player, Windows store apps
    I think the issue has more to do with the use Windows8/Unity3d version than a specific platform
    Unity3D 4.3.4f1 (30 day pro trial license), Windows 8.1

    This same issue does NOT appear in Win7, OSX
    (those systems have slightly older Unity3d versions - OSX has Unity3D 4.3.1 - don't know if this matters)
     
    Last edited: Mar 12, 2014
  37. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Its not related to this is it?
    http://forum.unity3d.com/threads/206070-New-Win-8-1-machine-with-VS-2013-gt-Errors

    Is there any further info in the log?

    Edit: or this
    http://answers.unity3d.com/questions/318216/internal-compiler-error-1.html
     
  38. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,125
    That is a build error - yes, I got that initially but then also installed Windows SDK 8.0 , VS2013 - the error I'm getting is in the editor (says I can't enter playmode before the errors are fixed)

    I do not know since the error string is "" - I will try disabling all antiviruses and let you know the results

    EDIT: Okay, disabling my anti virus and firewall fixed this issue. This is way weird that a firewall/antivirus will specifically choose to dislike 2D toolkit (I was using Avira Antivirus, Comodo firewall- not sure which one caused it but I think Avira).Thanks for your quick help!!

    2d toolkit rulez, no matter what the antiviruses say!
     
    Last edited: Mar 12, 2014
  39. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Glad you've got it figured out :)
     
  40. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    Can the toolkit still be used with 3.5.7? If so do I need to set certain things up for it to work or can it just be imported as normal?
     
  41. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It still works with 3.5.7
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    2D Toolkit 2.4 has been released with greatly improved in editor memory management with PNG textures, a new advanced collider tools and many more fixes and improvements.

    Grab it here http://2dtoolkit.com/forum/index.php/topic,3810.0.html
    or update on the asset store.
     
  43. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    Quick tilemap question.

    Is there an easy way to copy tilemap sections consisting of multiple layers at once? Especially between scenes? The layer-by-layer approach is too slow for me.


    Thank you!
     
  44. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    My problem is I have many layers. They are as follows:
    Walk: Z -0.5, no collide
    Walk 2: Z -0.4, no collide
    Walk 3: Z -0.3, no collide
    Collide: Z -0.2, collide
    Collide 2: Z -0.1, collide
    Hover: Z 0.8, no collide
    Hover 2: Z 0.9, no collide

    The reason I have so many layers is this:
    I needed a set of tiles that the player is in front of that don't collide (Walk). I needed a set of collide tiles (Collide). And I needed a set of hover tiles, that are in front of the player and also in front of tiles behind it but don't collide.

    The reason for the multiple mini-layers, for example Walk, Walk 2, and Walk 3, is to get things dynamic. I'll have a grass tile in Walk. Then a dirt path tile in Walk 2. Then an open door in Walk 3 that allows the player to enter a house. All encompassing the same tile.

    It's a Zelda-esque top-down view game. A typical house in the game will use all 7 of those layers in various areas of the outside of the house. Which makes it a bit of a pain to duplicate said house.


    Thank you.
     
  45. unikronsoftware

    unikronsoftware

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

    The tile map UI doesn't support multi layer cut and paste, but it does internally. There were various reasons we didn't enable it, but it can in theory be enabled. tk2dTileMapSceneGui.cs, PickUpBrush is called twice - there is a parameter allLayers that will grab all layers. I believe when we had it working we only supported cutting and pasting when on the lowest layer. If you run into any further issues post on the tk2d forum - at least the discussion will be properly threaded there. (http://2dtoolkit.com/forum/index.php)
     
  46. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    Thanks Unikron!

    Anyway, this next issue has been bugging me for two days now.

    Alright, I cave. I cannot figure out why my sprite isn't lighting up in Game mode in Unity with the 2D Toolkit, only in Editor mode.

    Things look fine in the Editor. I can even move the point light left and right and see accurate results. It's a Tk2dSpriteAnimator.
    $XiQ4j4v.png

    The shader on the material for the main character.
    $PgLTyig.png

    Sprite Collection seems fine.
    $ezp0o0f.png

    Normals seem fine (camera is down the Z axis at -10).
    $ANOth2k.png

    The point light itself seems fine.
    $hX5o5Kk.png

    And yet, in Game mode (also when I build and run), no light... (in next post)


    The only light that seems to work is Directional light. Spotlight or point lights do nothing. I've spent days on this and got nowhere. Any ideas?
     
    Last edited: Mar 18, 2014
  47. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
  48. ColonyGames

    ColonyGames

    Joined:
    Aug 24, 2013
    Posts:
    9
    I started a new scene from scratch.

    $Rolan8.png

    Same problem?

    Thought about it some more, then switched out the camera from the 2D Toolkit one for the standard one.

    $Rolan9.png

    And that fixed it. Any idea why the Td2k camera wasn't allowing the lights?


    Thank you :)
     
  49. unikronsoftware

    unikronsoftware

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

    This is due to a bug in Unity.
    http://issuetracker.unity3d.com/iss...custom-projection-matrix-is-set-on-the-camera
    That bug in particular was fixed in Unity 4.1.2, then broken again in 4.3. I've reported it again, but I don't know when it'll get fixed :(
    http://2dtoolkit.com/forum/index.php/topic,2015.msg10035.html#msg10035
     
  50. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Hello, I'm having blurry text as soon as I switch platform to IOS, both in Unity3d editor and on iphone device the text is blurry. This is not the case on Android, is there something to do about it?

    I'm using 2d toolkit 2.4 and newest Unity3d

    Thanks