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. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    It seems like this one's probably been asked, but I haven't been able to find it anywhere...

    Is there an easy way to keep all of the source textures used to build an atlas out of the final build? Does this happen already?

    With NGUI you can delete the source textures from your scene once they've been put into an atlas. On the flip side, the atlas isn't auto-updated when textures change and textures aren't removed from the atlas when they are deleted. I much prefer 2D toolkit's auto-updating, but if there's space being wasted in our builds I'd love to get it back
     
  2. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    @YourUncleBob - the source textures don't get included in the build (unless you've placed them in a resources directory, or somehow accidentally use them somewhere. The only thing that's used at runtime is the tk2dSpriteCollectionData object - which contains no references to the source textures. You're safe :)
     
  3. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi liven, I can't say if you will have any issues if you update - you should backup in case, or use version control on everything...
     
  4. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    Excellent, thanks.
     
  5. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    I have two request, maybe it's been covered, but I could not find anything, so here we go:

    1: In many cases, it's important to be able to show a texture within a 2d toolkit element that is not atlased. Typically the webcam texture. the catch here is that for example, the background graphic for the webcam texture is driven by 2d toolkit and is positionned on screen with a 2dtk camera and anchor

    It's difficult at the moment since it's not possible to define a sprite that is taking its texture from a raw reference, not from a collection. Is it something that has been addressed somehow or is currently cooking? I would imagine that a new component would need to be created, but before I go down that route, I wanted to make sure no one already came up with something like that.

    2: I need to create a progress bar with animated strippes, like this ones

    basically, I am very close to this, and all it requires is a new 2dtk shader where the overly texture uv is not taken from the atlas but rathe a flat uv, where offset and scale properties of the overly texture is taken into account.

    my shader scripting skills are bad, I did try but modifying Blend2TexVertexColor proved to difficult for me to implement. that shader is almost what I need, but the gradient texture uv is wrong and the offset and scale of the texture is not taken into account.

    I am pretty sure these needs are common, so hopefully there are existing solutions or directions I could take to achieve them.

    thanks,

    Jean
     
  6. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    Hi there Unikron! Like alot of the 2dtk users, I'll say you saved my life!

    I'm here to ask whether there is something I don't understand or if the pixel perfect feature is not so pixel perfect.

    I created a splash screen 720x480 for my game, the game is supposed to have a resolution of 720x480 of course. But when I import it and make it pixel-perfect, it does not cover the whole screen, in fact, I have to scale it to 13.3 with an orthographic camera of size 10.

    Thanks for your constant support!
     
  7. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It depends on how you've imported this, and what you'd like to display.

    1. Did you set the parameters on the sprite collection (height = 480, ortho size = 10) and then match the settings on the camera? If so, the sprite should be pixel perfect as soon as you create it.

    2. Alternatively, you can enable tk2dCamera on the sprite collection, and use a tk2dCamera instead of a normal camera. The sprite will be pixel perfect on the target device, and you can decide how that changes when the target resolution changes.
     
  8. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Both covered. I'll link you to solutions (you will probably have to register on our forum if you haven't already, as they're both in the private support area)

    1. Use runtime sprite collections. The next version will have these functions integrated into the core toolkit.
    http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,340.0.html

    2. There is a sample here which does precisely the same thing:
    http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,398.msg1900.html#msg1900

    Hope that helps.
     
  9. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
  10. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Hi everyone,

    I'm currently implementing a scene editor that extracts images from a psd file. I would like to include the atlas generation process in this scene editor so that upon importing new textures, they are automatically added to the sprite collection. Can someone tell me how to achieve this? I've tried to decode that from the scripts but apparently it is meant to be done through the tk2dSpriteCollectionEditorPopup. Is there a simple way to do this?

    Thanks,
    Clayton
     
  11. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Thanks a lot for these link, Unikron, I am very impressed and really pleased about these!

    have a great day!

    Jean
     
  12. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Hi everyone,

    I managed to figure this out. I'm sharing this code, maybe someone finds it useful.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. using tk2dEditor.SpriteCollectionEditor;
    7.  
    8. public class tk2dSpriteCollectionEditorHelper {
    9.  
    10.     tk2dSpriteCollection _spriteCollection;
    11.     SpriteCollectionProxy spriteCollectionProxy = null;
    12.    
    13.     public tk2dSpriteCollectionEditorHelper(tk2dSpriteCollection spriteCollection){
    14.         SetGenerator(spriteCollection);
    15.     }
    16.    
    17.     public SpriteCollectionProxy SpriteCollection{
    18.         get{
    19.             return spriteCollectionProxy;
    20.         }
    21.     }
    22.    
    23.     List<SpriteCollectionEditorEntry> entries = new List<SpriteCollectionEditorEntry>();
    24.    
    25.     void SetGenerator(tk2dSpriteCollection spriteCollection){
    26.         _spriteCollection = spriteCollection;
    27.         spriteCollectionProxy = new SpriteCollectionProxy(spriteCollection);
    28.         PopulateEntries();
    29.     }
    30.    
    31.     public void AddTexture(Texture2D t){
    32.         string name = spriteCollectionProxy.FindUniqueTextureName(t.name);
    33.         int slot = spriteCollectionProxy.FindOrCreateEmptySpriteSlot();
    34.         spriteCollectionProxy.textureParams[slot].name = name;
    35.         spriteCollectionProxy.textureParams[slot].colliderType = tk2dSpriteCollectionDefinition.ColliderType.None;
    36.         spriteCollectionProxy.textureRefs[slot] = t;
    37.         PopulateEntries();
    38.     }
    39.    
    40.     public void AddTextures(Texture2D[] textures){
    41.         foreach (Texture2D t in textures)
    42.         {
    43.             string name = spriteCollectionProxy.FindUniqueTextureName(t.name);
    44.             int slot = spriteCollectionProxy.FindOrCreateEmptySpriteSlot();
    45.             spriteCollectionProxy.textureParams[slot].name = name;
    46.             spriteCollectionProxy.textureParams[slot].colliderType = tk2dSpriteCollectionDefinition.ColliderType.None;
    47.             spriteCollectionProxy.textureRefs[slot] = t;
    48.         }
    49.         PopulateEntries();
    50.     }
    51.    
    52.     void PopulateEntries(){
    53.         entries = new List<SpriteCollectionEditorEntry>();
    54.        
    55.         if (spriteCollectionProxy == null)
    56.             return;
    57.  
    58.         for (int spriteIndex = 0; spriteIndex < spriteCollectionProxy.textureParams.Count; ++spriteIndex)
    59.         {
    60.             var sprite = spriteCollectionProxy.textureParams[spriteIndex];
    61.             var spriteSourceTexture = spriteCollectionProxy.textureRefs[spriteIndex];
    62.             if (spriteSourceTexture == null)
    63.                 continue;
    64.            
    65.             var newEntry = new SpriteCollectionEditorEntry();
    66.             newEntry.name = sprite.name;
    67.             newEntry.index = spriteIndex;
    68.             newEntry.type = SpriteCollectionEditorEntry.Type.Sprite;
    69.             entries.Add(newEntry);
    70.         }
    71.     }
    72.    
    73.     public void Commit(){
    74.         spriteCollectionProxy.CopyToTarget();
    75.         tk2dSpriteCollectionBuilder.ResetCurrentBuild();
    76.         tk2dSpriteCollectionBuilder.Rebuild(_spriteCollection);
    77.         spriteCollectionProxy.CopyFromSource();
    78.     }
    79. }
    80.  
     
  13. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Looks like you figured it out before I had a look at it. Just one thing - the proxy stuff isn't necessary, you can directly modify the spritecollection object. The parameter names are largely identical.
     
  14. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Hi unikron,

    Ok thanks for the heads-up. Will remove it! BTW, a big well done for tk2d... it is amazing! Keep it simple as it is! :)

    Thanks,
    Clayton
     
  15. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Unfortunatly this barbershop solution is clipping the texture, which means that I can not compose it and thus making it not possible to create an effect that will take into account the texture alpha. The loader bar strippes are within the loader bar graphics alpha.

    I am almost there by using the Blend2TexVertexColor but can't modify it so that I can use the scale and offset setting of the overlay texture. I guess it would need to use the second uv channel as well. The overlay slot would reference a normal texture, not an atlased one, and a color setting would likely help composing the overlay texture with alpha and color against the underlying texture.

    I am willing to pay to get this shader right, so pm me if someone is interested to get this done.

    bye,

    Jean
     
  16. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Hello, i want to ask about what is NOT animatable with Unitys animation system. I already figured that i cannot animate colors. Now i found i also cannot animate the t2dsprite scale property. I have set keyframes there and can even see the parameters changing according to the animation, but the sprite itself does not scale.
    Before i just animated the global scale, which worked, but i noticed quite a performance hit on iOS, which i am currently trying to overcome.

    I guess i could write an extra script with public values, animate those and pump that into the t2dkbasesprite. But that looks like a crazy solution to me.

    (i just updated to the very latest version of 2DTK, using it with Unity 3.5.6 Pro)
     
  17. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    @marjan,
    You also can't animate changing spriteIds. This is an unfortunate issue with the Unity animation system - it can't animate properties, just plain variables. In order to be able to animate these, you will need a function polling these values constantly which is not ideal - that crazy solution ain't that crazy after all, its much better than the alternative which is a constant overhead on everything. If you want to implement something like that, I strongly suggest implementing ONE class, and then linking all your animating sprites to it, rather than creating a component on each object. Its much much more efficient. (which is also why there isn't a built in solution out of the box, its hard to put constraints like this on).

    There is a workaround with scale though, if you can ensure all your sprites have non uniform scales, you don't lose batching, and get to use transform.localScale. So make sure your scales (on all sprites) are like 1, 1, 1.000001 and you'll be fine. You can check batching in Game view Stats.
     
  18. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Drop me an email at support@unikronsoftware or post on that thread with the barbershop one and I'll help out with this.
     
  19. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    I wonder if it would be possible to add fonts to atlases and keep the gradient functionality. I understand that this would require that the font draw calls remain separate from the sprite draw calls as they are when not sharing the atlas.

    What I'm really looking for with this is to get some memory back by having my fonts use some of the unused space in my atlas. It would also get rid of the extra dead space at the bottom of most of my font sheets. Another small benefit would be that it would reduce the draw calls in areas where I have multiple fonts on screen.

    The functionality that sprite sheets have, taking each frame and cramming it wherever it will fit in the atlas, even turning a frame on its side if need be, would also give us some potentially better packing than BMFont, especially when merging multiple fonts into a single atlas.
     
  20. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    That is a good suggestion - there doesn't seem an ability to choose overridden materials on fonts. I'll put it in the TODO. No promises on time scales, but I think it might be realistic for 1.80
     
  21. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    Great. I'll throw in one more suggestion while I'm at it. I added an Alpha Threshold to spriteCollection. This is the alpha value that's small enough to be considered transparent when building the atlas. We had a lot of wasted space in our atlases because we had some source art that had images surrounded by some really subtle semi-transparent glows. By setting our alpha threshold to 8 (/255), we were able to shrink by about 25% and fit back into a 2Kx2K atlas.

    In SpriteCollectionBuilder.ProcessTexture, you just compare alpha to the threshold value instead of 0. I considered adjusting the alphas just above the threshold to retain smooth edges, but a value of 8 was small enough that we couldn't see any differences in the edges in game.
     
  22. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    I'll look into this next time I'm adding another feature into the builder. Probably not for 1.80, as I'm trying to minimise code change there already, but should be OK for the version following that.
     
  23. unikronsoftware

    unikronsoftware

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

    kelley

    Joined:
    Oct 5, 2012
    Posts:
    11
    I recently posted a question on Unity Answers (original post here) and several people suggested 2D Toolkit. To recap, my situation is that I have several 2D animations playing at once. Each animation is about 30 frames long and the frames are very large (original size is more than 2048 square) rectangular PNGs. The animations have transparent parts and are layered on top of one another in z-space to give a 3D effect using 2D planes (think Paper Mario). We are getting a lot of delay while loading the frames in from Resources on the first loop of the animations.

    I'd like to know if you think 2D Toolkit would help reduce this delay any. We are hesitant to purchase the plugin since we are not sure if it will be a noticeable performance improvement. Since the delay is caused by the sheer size of the frames, we're not sure if 2D Toolkit will help.
     
  25. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    2D Toolkit will help massively if you have a lot of transparent areas in your textures, as it will automatically trim them and handle all the repositioning for you automatically. Drop me an email (support@unikronsoftware.com) with an example texture (you can blank out color info if you like) and I should be able to tell you how well it'll work. Also, how many layered sprites do you have there? The fillrate saving from this could be pretty huge too.

    If there is a huge amount that can be trimmed away (there is more than one strategy available here with 2D Toolkit), then you'll get massive gains as the atlas will be built out of these tiny bits as opposed to your large source texture.
     
  26. paulbaker

    paulbaker

    Joined:
    Aug 29, 2012
    Posts:
    58
    Any tips or suggested plugins for localising text when using 2D Toolkit?
     
  27. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    We went with the M2H Localization package. http://u3d.as/content/m2h/localization-package/1Ya. I'd highly recommend it.

    To integrate it into the 2D Toolkit, I just added a TextKey and TextKeySheet field to tk2dTextMesh and modified tk2dTextMesh.Awake to look up the localized text on any textmesh that had a TextKey.

    Code (csharp):
    1.  
    2. void Awake()
    3. {
    4.     if(Application.isPlaying)
    5.     {
    6.         if(!string.IsNullOrEmpty(_textKey))
    7.         {
    8.             if(!string.IsNullOrEmpty(_textKeySheet))
    9.                 text = Language.Get (_textKey,_textKeySheet);
    10.             else
    11.                 text = Language.Get (_textKey);
    12.         }
    13.     }      
    14.    
    15.     if (pixelPerfect)
    16.         MakePixelPerfect();
    17.        
    18.     // force rebuild when awakened, for when the object has been pooled, etc
    19.     // this is probably not the best way to do it
    20.     updateFlags = UpdateFlags.UpdateBuffers;
    21.        
    22.         Init();
    23. }
    24.  
     
  28. G_Koko

    G_Koko

    Joined:
    Aug 25, 2012
    Posts:
    30
    Hi Unikron,

    One question, i duplicate many "sprites animations" and when i export the package, include many of the "animated sprites" that doesn't belong from that sprites animations. I'm making different versions of these because of the resolution of the devices (iPad, iPhone, 3GS). I don't know if there's a solution without making all the sprites animations again and without duplicate another one like i did.

    I don't know if i'm really clear with my question.

    Thanks.
     
  29. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Last edited: Oct 12, 2012
  30. mu-kow

    mu-kow

    Joined:
    May 15, 2012
    Posts:
    106
    @unikronsoftware

    do you declare ALL of your vertices in a counter-clockwise fashion?
     
  31. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    It depends, when the sprite is flipped using .scale, it will be CW - that's why the shaders are 2 sided.
     
  32. mu-kow

    mu-kow

    Joined:
    May 15, 2012
    Posts:
    106
    i see, i'm adding a bit of custom functionality to the sprite collection editor and i've just noticed so far that the handles are put into the array in a CCW order and the polygon collider the same... so i just wondered.
     
  33. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Its always built CCW, its just at runtime where it could be CW.
     
  34. Peeffy

    Peeffy

    Joined:
    Oct 13, 2012
    Posts:
    7
    I wanna make 2D mobile games and a friend of mine told me to purchase this asset,but I'm not sure exactly what it does.Will this make the process of making the game easier?Will this lower the time that takes to make games?
     
  35. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Want to make 2D games with Unity? buy 2DToolkit

    Here's what you can do with 2DToolkit (it's a beta video)

    http://m.youtube.com/#/watch?v=0b1Yo7fDFfU
     
  36. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    What it does is all the boilerplate stuff - handling atlases, building geometry / text meshes and some special optimizations (sprite dicing, custom sprite geometry, etc). We try very hard to keep out of your way, and don't impose any forced workflows beyond creating a spritecollection. In 1.80 which is due out anytime now, it also does atlas / font / sprite swapping for different resolutions. Here is a link to the docs - http://unikronsoftware.com/2dtoolkit/doc/.

    Edit: I forgot to mention, it also does efficient tilemaps.
     
  37. Peeffy

    Peeffy

    Joined:
    Oct 13, 2012
    Posts:
    7
    Seems nice.I'm between this and Uni2D,both seems very nice.Mind telling me the difference between they both?
     
  38. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Uni2D has one feature which we don't have, which is automatic collider generation. With ours you have to build them manually, and we don't (yet) support composite colliders.
    Edit: Also, the workflow is probably simpler, but at a cost - you don't get the level of control as you do in 2D Toolkit. This is down to personal preference; I prefer explicit control over textures and atlas sources.

    The focus of both plugins is also quite different.
    Ours is a general purpose toolkit - 2D Toolkit supports flipbook animated sprites, text, tilemaps, static sprite batchers, advanced atlas generation settings (sprite dicing, dithering, etc) and soon, automatic atlas switching.
     
  39. Ghopper21

    Ghopper21

    Joined:
    Aug 24, 2012
    Posts:
    170
    I'm looking into the difference between Ex2D and 2D Toolkit.

    Specifically, in a blog entry about 7 reasons to choose Ex2D, the maker of Ex2D says:

    Does what this quote says about "other 2D solution" apply to 2D Toolkit? (Apologies if this question has been asked before! I've searched around but not found this specific question addressed.)
     
  40. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Nope. Doesn't apply to 2D Toolkit. You don't need to create prefabs of sprites / textmeshes. You can if you want to though, there's nothing stopping you doing whatever you want with the 2D Toolkit objects.

    For what its worth, 2D Toolkit imposes a lot less components at runtime than Ex2D, and the runtime is significantly leaner due to how everything is precomputed and prebuilt in editor scripts.
     
    Last edited: Oct 15, 2012
  41. test84

    test84

    Joined:
    Jun 28, 2011
    Posts:
    25
    Hi,

    What can I read/watch in order to get up and running in no time? I tried reading the getting started parts of the doc but they are teaching various aspects of tk2d but I'm a step behind and want to know which type of sprite to use and where.'

    For example the difference between sprite types, batcher and such. More interested to know the cases that one should use one of them.

    Thanks.
     
  42. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    All you need to get started with are sprites (for static sprites), animated sprites and fonts. Ignore the rest until you're comfortable with the system.

    The static sprite batcher is an optimization which can be set up much later into development. For example,the static sprite batcher is used when you have loads of static background sprites - it merges everything down into one big object to save a fair bit of runtime overhead.

    Edit: if you have any further questions, feel free to ask.
     
  43. test84

    test84

    Joined:
    Jun 28, 2011
    Posts:
    25
    Thanks.

    I actually found it very easy! With me coming from reading a few SM2 tutorials I was preparing myself for a hard ride but it was fairly easy, so far. I've followed your website's tutorial and they were fine.

    I have one question though, on the Level Creation Tips page you wrote and I quote "Use the collider set-up to mask impassable ground and platforms. Here is the previous scene with colliders set-up as an example." But I don't get what you mean by that. Please elaborate if possible.

    (EDIT:
    You meant that whenever we have a lot of static objects, we better of doing static batching on them. But "when" should we do it? What if our level is just a few sprites, like 20, but each have rigid bodies, should we do it then?)

    And when I'm working 2D, what should be concerned more, batches or draw calls and also how I can evaluate them to see whether I'm good or not.
     
  44. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    The static sprite batcher is just for static objects - so no rigidbodies, or otherwise moving objects in there.
    If you have colliders set up on sprites within a static sprite batcher - the colliders are merged automatically when the static sprite batcher is committed. Basically you set up your walls and stuff in there (with the colliders set up on individual objects initially), and 2D Toolkit generates an optimal final mesh.

    Draw calls is what you want to minimize. Keep it as low as possible. Sprites from the same sprite collection should batch - so try to keep the number of visible sprite collections to a minimum as well. With regards to how many is good, it really depends on the platform, and how much other processing your game does.
     
  45. speewave

    speewave

    Joined:
    Oct 4, 2012
    Posts:
    8
    Will you (or do you) guys have a Trial version... (maybe limited features, but full-featured would be best)

    The videos and every thing look great and it really seems to integrate nicely in to unity! however, i'm normally the "try before you buy" type, also i'd like to really know i'm going to use it before i spend the money)
     
  46. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    @speewave, there isn't a trial mainly because its distributed as full source. Now that 1.80 has been released, I've got some plans to investigate the feasibility a limited trial.

    Drop me an email at support@unikronsoftware.com and I'll see what I can do.
     
  47. Ghopper21

    Ghopper21

    Joined:
    Aug 24, 2012
    Posts:
    170
    Thanks Unikron for answering my previous question about the comparison with ex2D.

    Another question: are there any examples of full games made with 2D Toolkit with source code available, for learning purposes? I didn't see any in your online documentation and I saw only games released without source code in your forum showcase.

    Thanks!
     
  48. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    @Ghopper21 - there aren't any examples of full games. 2D Toolkit provides a 2D framework, gameplay is very much your responsibility. There are a lot of snippets and code on how to do common things in our forum (http://unikronsoftware.com/2dtoolkit/forum).
     
  49. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Hi Unikron!

    I have a question about sprite scale and position... I have created a sprite with other sprites as children of that sprite.
    When I scale the parent, I have to scale the children by hand, which is ok. But I was wondering... the position of the children does not update relatively to the parent... any idea of how to do that?
    Thanks a thanks again for your incredible support to all of us!

    fm.
     
  50. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    Hi there are a few ways to do this. First, if you have a hierarchy of sprites set up, you can use transform.scale instead of sprite.scale. This will scale properly, but by default will increase draw calls. The trick here is to make sure the scale on the root object is non-uniform, so make it 1, 1, 1.001. This whole object will draw in 1 draw call. You can use this trick to batch multiple of these types of objects together too - just make them all non-uniform. The actual value doesn't seem to matter.

    Edit: I suggest trying this before any of the other ways. It is by far the most convenient.
     
    Last edited: Oct 22, 2012