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

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

  1. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    2D Toolkit is now available on the Asset Store for $65.
    Official website with FAQs and support form
    Official documentation wiki
    2D Toolkit on the Asset Store


    2D Toolkit is a set of tools to provide an efficient 2D sprite and text system which integrates seamlessly into the Unity environment.

    Features:

    Sprites
    • Fire and forget atlasing system. Set it up once, and it will be automatically regenerated when it needs to be.
    • Automatically cut up sprites, eliminates empty space in textures and saves altas area and fill-rate.
    • Source sprites from spritesheets, lets you use your existing assets and without changing your workflow.
    • Automatically generate multiple atlases when necessary from one Sprite Collection.
    • Supports arbitrarily sized sprites.
    • Set up anchor points so your sprites rotate at the right points, and to line up animated sprites.
    • Supports pixel perfect rendering on orthographic and perspective cameras.
    • Efficient batching system for background static sprites. Create combined static sprite meshes seamlessly and efficiently.
    • Scale sprites without breaking dynamic batching.
    • As much data as possible is precomputed offline, runtime transformations are kept to a minimum.
    • User friendly editor, creating and using sprites has never been simpler!
    • New! Set up colliders within the interface
    • New! Supports automatic and custom box collider set-up
    • New! Polygon collider editor - Set up polygon colliders quickly and efficiently

    Sprite Animations
    • Easily and quickly build large libraries of sprite animations for your projects.
    • Supports arbitrarily sized sprites for animation.
    • Sprites for animations can be sourced from any number of atlases.
    • Easy to use in-game API.

    Text
    • Use bitmap fonts created in BMFont / Hiero.
    • Tint and scale your text meshes without breaking dynamic batching.
    • Supports vertical gradients.
    • New! Supports gradient textures and inline style changes.


    Gradient text meshes demo
    [​IMG]

    Collider demo
    [​IMG]
    Link to webplayer: ColliderDemo

    New videos

    Static sprite batcher - Efficient batching made simple!

    This demo is included as a scene in version 1.01

    Building and animating a segmented spider

    This demo is included as a scene in version 1.01

    Using 2d Toolkit with Unity physics

    This demo is included as a scene in version 1.01

    The following videos were created during development, demonstrating the main features. Some of these are slightly out of date. I will update them at the next opportunity.

    Sprite workflow Part 1


    Sprite workflow Part 2


    Pixel perfect sprites and sprite animations


    Font workflow
    Last edited: Mar 23, 2012
  2. okimoki

    okimoki

    New Member

    Joined:
    May 13, 2010
    Messages:
    113
    wowww.. this looks awesome!!!! too bad i can't afford it, i would really need it right now..
    really amazing tool!!!
  3. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Just a general update about the product and where we are intending on taking it in the future.

    Coming very soon is a version 1.01, containing a few bug fixes and a few minor features. We intend on submitting that on Monday. We are also going to link to this thread, so if anyone has any issues or suggestions there will be a place to discuss them. We are using the library in house for our own games, so we will be fixing issues and improving workflow as time goes on. We are considering svn access for those who have purchased the product, let us know if this sounds useful.

    We are looking into redoing the videos above with the final version. The background batching will need some demonstrating as well, as its hard to convey how easy it becomes to set it up in just a blurb of text.

    Finally, for the future, we are planning a few free paid add-ons. Before anyone jumps to any conclusions, all features, small or big to the core system are going to be free.

    We are, however, considering add-ons for specific game types, eg. for physics based games, we have a collision hull drawing add-on in house. This obviously isn't anywhere near releasable right now. Another paid add-on we had in mind was creating tiled background shapes (eg. draw a polygon shape and it will fill it and add decorations on the edges automatically, again using the batching system). We don't anticipate anyone needing absolutely all the add-ons, and its obviously unfair to increase the price of the product to justify increased engineering costs.

    Let us know what you think, and as always, we are available on PM to sort out any issues.

    unikron
  4. codex

    codex

    New Member

    Joined:
    Feb 10, 2010
    Messages:
    51
    Wow it looks amazing is it possible to get a demo? Would love to test it out :)

    C
  5. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Hi Codex,

    Due to the nature of the product, it would be quite hard to provide a demo. However, if you would like to see anything in particular demonstrated, we will certainly be able to create another video for you.
  6. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Posted new tutorial demo videos in the first post.
    Version 1.01 coming soon as an update on the asset store, with a few bug fixes and some new demos.

    If you have purchased the product and are having issues, please send a PM. We will send the patch your way ASAP.
    Last edited: Jun 21, 2011
  7. yannalaplage

    yannalaplage

    New Member

    Joined:
    Jul 15, 2010
    Messages:
    31
    Hi,
    I'm already a sprite manager 2 user, what are your advantage and maybe weakness to this system ?
    thanks,
    yann.
  8. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Hi,

    We think our main advantage is the simplicity of the workflow, and how everything integrates quite seamlessly with the rest of Unity.

    You also get full control over atlas creation, and you can set up dicing which can save a large amount of texture space and not to mention fill rate. Check out the video Sprite workflow, part2 for a demonstration of that. In addition to that, with the built in premultiplied shaders (which are enabled by default). you can have additive and normal blended sprites from within the same draw call.

    The sprite batcher too is another tool which speeds up creation of backgrounds, and merges them down to one mesh after editing. You can also set up arbitrary pivot points on your sprite easily, which lets you easily create segmented characters as shown in the spider video.

    The back end provides clean, efficient and easy to use data, so you can extend the system easily too.

    unikron
  9. yannalaplage

    yannalaplage

    New Member

    Joined:
    Jul 15, 2010
    Messages:
    31
    ok, I'll give it a try then.
    I think it is interresting that you use it yourself "in production".
    Thanks for this nice unity extension and I'm puzzled about your premultiplied shader, could be very handy if it does what I suppose.
    best regard,
    yann.
  10. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    When the premultiplied shader is enabled, the alpha channel of the source textures are premultiplied with the colour channels. This is done transparently in the atlas build stage so you don't have to bother doing any of that processing by yourself. You can also set individual textures as additive, and the build stage will automatically create the appropriate data so basically you can draw normal transparency and additive transparency with the same draw call.

    unikron
  11. okimoki

    okimoki

    New Member

    Joined:
    May 13, 2010
    Messages:
    113
    arghhhhhh!!! i hate you!!!! now i have to buy this.. new videos convinced me.. i think it will save me some time in a long run..
    a question before i mindlessly buy it this instance and later regret it..
    "Bug fix: Creating sprite collection now works on MacOS."..does everything work on Mac? i dont want to buy it and later find out that 50% of features only work on windows :)
    Please answer ASAP :)
  12. Trölldinger

    Trölldinger

    Member

    Joined:
    Jul 8, 2009
    Messages:
    200
    hi unikron, i have strange problems animating a sprite by scripts. when i use the play function on Update/FixedUpdate, character only stays in first frame of animation i want play. Maybe you need to make another example demo for demonstrate make animation behaviours by script (do the proper animation with the proper action) and explain better the API documentation (maybe putting some API examples and extending a bit, because not explains enough for manipulate the extension by scripts).

    this toolkit is great, but with a little more of API documentation/examples and a animation behaviour example could be greater.
  13. nab477

    nab477

    New Member

    Joined:
    Jun 14, 2011
    Messages:
    46
    @DonBarksGheist: I still didn't buy the library, but I think you should make sure that u're not calling a PlayAnimation method (no matter what library u use) everytime update is called. (call once give it a few frames to do the animation only call again if you intend to change it)
    but as i said, this is a generic answer, perhaps unikron can provide detailed info if the problem isn't solved


    very interesting

    I don't need any of them right now, but I can see that both of these ideas are very interesting indeed

    (if you need more inspiration, see some of the tools that were made for farseer physics engine on codeplex, (e.g. convex decomposition hull, boolean operations, paths of objects ...etc)

    but I don't need much of that for now either :p

    what I'm interested in is to know if you have any plans for a future plugin that provide customized character animations like the one in the spider example but for human characters
    (example: provide torso, head, arm, leg provide an editor for an animator to animate them save the animations to a file then read those animations to move my own character that uses the same (or customized) parts (head, torso ...etc) )

    now this, I'm very interested in for the future !!
    (starting a project now with temp characters later I might have to implement it myself or find an alternative, but if it'll be provided as a component, I'd be an early supporter)
  14. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    @okimoki - as mentioned in the PM, as far as I am aware all features work on mac. We do test on Mac, but not as often as on Windows; hence the bug slipping through our testing process. It was reported by one of our customers and we fixed it ASAP. We intend on fully supporting mac so if you have any issues, we will certainly fix them for you.
  15. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    @DonBarksGheist

    If you call Play every frame from Update / FixedUpdate, the animation will be stuck on the first frame, as it will restart every frame. The idea is, you call Play on the AnimatedSprite when state changes, and forget about it. You can register a delegate to animationCompleteDelegate to be notified when the animation has completed playing, for example, if you wish to chain another animation or revert to idle. I will PM more details.

    Regarding a demo, that will certainly be done. What seemed obvious to us, clearly isn't. That's what this thread is for, and we will certainly act on feedback. Expect a PM soon with a demo, the demo will be queued up for 1.02 release sometime in the future.

    Regards,
    unikron
  16. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216

    I had a thought about that, and I believe you can do that with the current system without any modifications.

    You set up sprites exactly like the spider demo. You can then set up a prefab to contain this. At that point, you give it to your artist to set up animations using the built in Unity Animation editor.

    You can then change individual sprites from code, setting spriteId to change the currently drawn sprite. You can use GetSpriteIdByName to find a sprite from the current collection; more on this later. The thing which makes this all work, is the fact that you can set up anchor points uniquely for each sprite; hence you can set up the sprites so everything links together at the right places.

    If you have a large number of components, and need to pick across sprite collections, you can do pretty much the same thing, but use AnimatedSprites instead, setting each animation clip to "Single" so all it does is switch the sprite. The added bonus to this is, making any of the customizable parts animate "Just Works".

    You can also trigger mouth movements from the animation editor, or from code.
    If you need further info, feel free to PM. I would get a demo done, but our artists are all preoccupied with getting our games done.


    Regards,
    unikron
  17. Paris

    Paris

    New Member

    Joined:
    Oct 31, 2008
    Messages:
    100
    Is this compatible with iOS/Android?
  18. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    @Paris

    Absolutely. The primary target for this system was the mobile platforms, hence the emphasis on batching. It uses the Unity batching system in addition to the static sprite batcher shown above, so you can get very high batching throughput on iOS and Android.
  19. Skjalg

    Skjalg

    Member

    Joined:
    May 25, 2009
    Messages:
    68
    Can you create text with outline (stroke) easily or do you have to double up the text and have the outline version slightly larger in the background?
  20. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    @Skjalg, the text with the outline is created in BMFont (in this case). You can do the same with Hiero. This is probably the most efficient way of doing it in game, as there is no additional processing.

    If you wish, you can create a second copy and overlay it, or modify the built in TextMesh class to do it automatically for you.
  21. nab477

    nab477

    New Member

    Joined:
    Jun 14, 2011
    Messages:
    46
    if i may make a lil suggestion for future releases,

    add the ability to add a solid color
    if possible, allow it to be gradient !!

    I can't describe it as a bug, but the editor keeps pumping errors every now then while using the editor, which is a lil annoying
    however, when the game is running, (if you clear the log first), it stays clear runs in a stable fashion, which makes it a low importance request !!
  22. Jodon

    Jodon

    Member

    Joined:
    Sep 12, 2010
    Messages:
    101
    Two things I've run into:

    When you make a BMFont, I only usually include type-able characters (about 90 or so). When you enter that number into the number of characters field, you get a bunch of null accesses. You actually need to keep that value high, even though you're only using 90 characters. Reason being it appears to use a direct index which corresponds to the character you've typed, rather than doing something "more clever". So not sure why that value's exposed.

    The second thing I've run into is a bunch of null accesses when somehow the Sprite data gets corrupt. The SpriteId of one of my Sprites was -1 somehow (we're using SVN here, so not sure if a bad checkin had something to do with it, but the data was all there). You'll know you've run across this error when your Inspector refuses to render correctly. The way to alleviate this problem is to change your Inspector to Debug mode, then change the values, then back to Normal mode.

    Other than that, I really like the workflow and the price. Very reasonable, made the purchase a no-brainer.
    Last edited: Jun 26, 2011
  23. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Hi,

    Could you explain this in more detail? Do you mean to the sprite or the textmesh (which already supports gradients)?

    Is this the "Cleaning up leaked objects in scene since no game object, component or manager is referencing them. Mesh has been leaked 11 times." message? We seem to get that when using procedural meshes in the editor, even outside the 2d toolkit. We haven't really spent any time trying to fix it, as it seems to only occur in the editor, and doesn't affect in game performance memory usage / performance in any way.

    Regards,
    unikron
  24. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Two things I've run into:

    You are right, this value shouldn't really be exposed, not as-is anyway. The only 2 values which should be allowed are 128 and 256, depending on whether you need a full ascii char set or not. I think we will simply disable that and store 256 characters internally, the overhead of that being negligible in the grand scheme of things. This will be removed in the next release, thanks for your feedback.

    We had this happen once on our game, and that was when we were undergoing major restructuring renaming all the classes before we released 2d toolkit. It occurs when the sprite can't find the sprite collection (eg. when it loses metadata). We thought it was improbable that this could happen when not doing crazy things like we were, but thinking about it, it could really happen if SVN somehow messed up the metadata. We will try to add some code to catch this case and fix it for the next update.


    UPDATE: Both of these have now been resolved and will be in the 1.02 update.



    Glad you like it.

    unikron
    Last edited: Jun 26, 2011
  25. nab477

    nab477

    New Member

    Joined:
    Jun 14, 2011
    Messages:
    46
    Hi,
    I meant a square full of 1 color, I think i can explain it better by saying how i usually do it (in all engines, but still didn't try it with tk2d)

    I would usually make a 1x1 white pixel, then tint it with the color I want resize it to whatever i want it to be.
    therefore, I get a solid color square of whatever size/color I want.

    in Unity, I noticed that it would need to set the filter mode to point before i can actually use it, otherwise, it'll be blurred out.

    anyway, it's not that important, but it'll make life easier for anybody who'd need a square filled with a solid color.
  26. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216

    You can actually do that with 2d toolkit with or without filtering enabled. Try the following steps:
    1. Create a while 1x1 pixel texture and add it to your sprite collection
    2. Create a sprite and set it to use your texture, change the scale on the sprite accordingly. You can now tint your white square.

    You will notice that the edges are blurred, as it filters outward to transparent. You can change that behaviour by:
    1. Select your sprite collection, click edit
    2. Find your texture, set Pad to "Extend"
    3. Click commit.

    You should now have a solid colored box in your scene.

    You can easily change this to support gradients, look into the TextMesh implementation for how its done in there. We won't be adding that as a feature, as it is fairly specific and will add additional overhead to the system. If you are implementing this, we suggest you create copy of the tk2dSprite class and go from there, ideally storing it outside the tk2d directory structure, so you don't have any issues with upgrades later.


    unikron
  27. Jodon

    Jodon

    Member

    Joined:
    Sep 12, 2010
    Messages:
    101
    Actually, I've run into a major issue. The sprite collections don't persist over multiple launches. I can generate the Sprite Data, then I can go to a command prompt, do a "touch data" (to renew the data), then Unity detects a change and reloads the data. The spriteDefinitions come in as length 0. This seems to indicate the tk2dSpriteDefinition does not get serialized properly. I'll have to dig into it to figure out why that is, but that's the behaviour I'm experiencing.

    Unfortunately that's a deal breaker for me as I can't actually use the library to create levels yet.
  28. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    What do you mean by "touch data"? I will PM you my email address, it'll be easier to continue there.

    Resolved The problem has been resolved, it was related to the other issue Jodon was having with sprite data getting corrupted.

    This fix will be included in 1.02 some time this week.
    Last edited: Jun 27, 2011
  29. Jodon

    Jodon

    Member

    Joined:
    Sep 12, 2010
    Messages:
    101
    Just thought I'd update the thread in case others are reading / experiencing the issue:

    Unikron was able to solve the issue for me. It will be fixed through code in the next release. In the meantime, the bug appears when you corrupt your Sprite Collections. Make sure to fix-up all your SpriteCollections so no "null accesses" occur in the console before you re-commit your SpriteCollections. You can right-click on your SpriteCollection_Data/data.prefab file and click "Re-import" to see if it's correct or not. Fix-up all your Sprite Collections / Animations so no SpriteId is set to "-1". You can do that in Inspector Debug mode.

    Cheers and thanks Unikron!
  30. nab477

    nab477

    New Member

    Joined:
    Jun 14, 2011
    Messages:
    46
    suggestion: please make better documentation !!
    especially in regards to the API how to build things using script

    my current situation:
    I'm trying to build a framework for myself it'll be all in code,
    so, I'm struggling with how to create a sprite from code

    so far, I created a gameobject, added a tk2dSprite

    then tried to call SwitchCollectionAndSprite(resourceSpriteCollection.spriteCollection, 0)
    it gives me an error NullReferencException in tk2dSprite line 101

    even tried adding the MeshRenderer MeshFilter before calling it, still the same result !!

    can you consider having a tutorial for creating sprites by code please ?
  31. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    We can certainly do that. We didn't envisage anyone creating sprites from code like that, though, which is why we didn't bother documenting it apart from the (few) comments in the codebase. We documented the few functions we actually envisaged people using, i.e. changing color, spriteId, scale, etc. once the sprite has been set up.

    When we need to do something like that, we usually create a prefab and instantiate that. That way, we get the benefit of being able to visually set up the sprite, and not have to hard code any strings (to find texture names, etc) in code. Please do consider setting it up like that, otherwise send us a PM and we'll send you some code on creating a sprite in script.

    Regards,
    unikron
  32. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Version 1.02 has been accepted to the Asset Store!

    Changelist:
    - Bug fix: sprite Id fix for when data is corrupted
    - Bug fix: unable to create sprite collection in project root
    - Hidden number of characters on the font. This shouldn't have been visible in the first place.
    - Added new animation demo

    unikron
  33. nab477

    nab477

    New Member

    Joined:
    Jun 14, 2011
    Messages:
    46
    actually that does make sense

    I refactored rearranged the code to use prefabs instead it's working as it was intended to be.

    thanks for the help
  34. Jodon

    Jodon

    Member

    Joined:
    Sep 12, 2010
    Messages:
    101
    Hello again! I have two feature requests:

    1. Multi-line text. So when it encounters \n or the shift-enter trick in the editor, it will drop to the next line.
    2. When it generates the atlases, the ability to configure no-mipmaps (or have that be the default, since it's targeted for 2d games). I also find mipmap blending to be useful for certain mipmaps that scale poorly, but I generally use no mipmaps. I can always just change the code myself I guess, but I figure new users might find that their newly made sprites don't scale well.
  35. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Thanks for bringing that issue up though, we never thought anyone would use it like that. I will add some notes in the documentation on this for the next update.
  36. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    1. Multi line is easy enough to implement, we'll get it in the next update.
    2. You can go and change the texture properties once its created it the first time, use the "Atlas Texture" shortcut on the Sprite Collection. Also compression is enabled by default, you may want to turn that off too.

    Regards,
    unikron
  37. aigam

    aigam

    Member

    Joined:
    Dec 31, 2005
    Messages:
    160
    I was really impressed by the videos and the workflow, it is almost perfect for me, so even when I have sprite manager, for sure I will purchase this product!

    One Question:
    I want to use a very big BG. The general idea is that it will load and unload the BG areas based on camera position. the question is, I can instantiate sprites from code?

    Thks, a fantastic product.
  38. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    You can instantiate sprites from code, but that isn't documented. The recommended way to do this is to create a prefab and instantiate that. That way you can set up a sprite visually, or a static sprite batcher, and instantiate that instead of doing it entirely in code. Send us a pm if this won't work for you and we will get you some code to do this.

    Unikron
  39. gabidof

    gabidof

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    14
    Hi, i'm purchased this feature, but now i have a problem, a bug. When i tried to make a new Sprite Animation in the Project View, don't show me the options to choose the sprites collection. I wan't to know how to resolve that.

    Thanks.
  40. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Hi,

    I need more info, will continue in PM.

    Unikron
  41. gabidof

    gabidof

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    14
    Well, in the beginning there's no problem with the Create -> Sprite Animation. But now, i don't know why, when i do this, whe the Sprite Animarion it's create and i select to put the Sprite Collection to make the Animation, in the Inspector don't show me the options to select the Sprite Collection. Only show me the transform and the Tk 2d Sprite Animation (Script).

    I need to resolve that, because i can't make the animation with this.

    Thanks.
  42. gabidof

    gabidof

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    14
    I found the error, in the console show me this. IndexOutOfRangeException: Array index is out of range.
    tk2dSpriteAnimationEditor.InitializeInspector () (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteAnimationEditor.cs:35)
    tk2dSpriteAnimationEditor.OnInspectorGUI () (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteAnimationEditor.cs:60)
    UnityEditor.InspectorWindow.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
  43. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    I will try to reproduce this. As mentioned in the pm, it would help if you could send the scene over for me. Also, one of us will be on google talk, so you can catch us there too.

    Regards,
    Unikron
  44. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    Based on your error message, it looks like you haven't clicked Commit on your SpriteCollection after modifying it (eg. adding a new sprite, etc.). We have added an error message for when this happens, and when another case occurs as well. Sent a PM with the updated file for you to replace.

    This will be in the next update.

    Regards,
    unikron
  45. aigam

    aigam

    Member

    Joined:
    Dec 31, 2005
    Messages:
    160
    Thks for your help, it works perfectly.

    Hey, I love that the sprite scale is independent of the mesh scale, so I can scale the object even if it is in pixel perfect :D
  46. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    The main reason the scale is separate is that the regular "scale" parameter on the Unity Transform component breaks batching; i.e. 2 sprites from the same collection, with different scales in the Transform, will be broken up into two draw calls.

    There are still cases where using it is preferred though, for instance, in one of our games, when an object is destroyed we simply scale down to 0 over time. Doing this using Sprite.scale will cause the mesh to be updated, which we can avoid and balance with draw calls by simply using Transform.scale.

    The pixel perfect code ignores the Transform.scale parameter to encourage using Sprite.scale instead. Our artists keep a close eye on draw calls, and for static scenes which they set up visually, generally the draw call count should be as low as possible.

    unikron
  47. gabidof

    gabidof

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    14
    Thanks for the help. This feature for a 2D game ROCKS!
  48. aigam

    aigam

    Member

    Joined:
    Dec 31, 2005
    Messages:
    160
    Hi!

    Thks for the tip about how scale works.
    I have two "problems" or questions:
    1- When I add an image to sprite collection it does not automatically cut up the sprites, I have to select DICE and then the full size of the image (to avoid it to divide the image in various parts). Is there any option to make it by default to cut up sprites?
    2- When the number of sprites is filling an atlas bigger than 2048, it scales down the images so it fills the 2048 sprite. Is ok, but maybe we can have some warning? or it can be better if the image is divided in two.

    Thks!
  49. unikronsoftware

    unikronsoftware

    Member

    Joined:
    May 21, 2011
    Messages:
    1,216
    By cut up sprites do you mean to get rid of areas where alpha = 0? If so, this was planned for the next release sometime next week.

    We had actually added a warning before you requested this, so whenever the atlas exceeds the maximum texture size, it will fire up a messagebox reminding you to fix it!
  50. aigam

    aigam

    Member

    Joined:
    Dec 31, 2005
    Messages:
    160
    Yeah, exactly, thks!