Search Unity

ex2D - the best 2D sprite solution for Unity [RELEASED]

Discussion in 'Assets and Asset Store' started by johnny_karas, Aug 24, 2011.

  1. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi michaelkamms,

    Basically you should test pixel perfect when your Game View is opened and running correctly, or you should set the exPxielPerfectCamera and choose Custom Resolution then put the resolution you want.

    See if this works
     
  2. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi undream,

    I'm not sure what is exactly Premultiply do. Can you show me the tools with this features? In my experience, you can solve the dots/lines problem by making alpha texture in this way: http://unity3d.com/support/documentation/Manual/HOWTO-alphamaps.html. And you can turn the Atlas Texture to Pixel Filter to avoid problem.
     
  3. undream

    undream

    Joined:
    Dec 24, 2011
    Posts:
    27
    Hello,
    The premultiply uses the PNG alpha without needing these actions. It is supported in all adobe tools, so, most of the designers coming from those toolsets are definitely used to that simple workflow instead of editing each texture with unnecessary background color elements.

    2D Toolkit and EasyMotion2D has this feature - which is VERY nice !
     
  4. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi myprabath01,

    The layer manager is a new concept and feature for 2D games. We've been discuss for a long time to make this decision. The other system especially the animation will have a heavy depends on this new layer system, so I hope you can understand.

    Regards,
    Wu
     
  5. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    I created a sprite and added a Box Collider component.

    In a C# script I have the following code:

    Code (csharp):
    1.  
    2.     void onMouseEnter()
    3.     {
    4.         Debug.Log("build tile");
    5.     }
    6.  
    I attach it to an ex2D sprite. I enable collision helper and make sure that it's synced. When I run the game and mouse over the box I get no log entries. Am I missing a step?
     
    Last edited: Dec 26, 2011
  6. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi undream,

    Sorry for my bad understanding. But I still don't got it? What is exactly of the premultiply alpha? Is it a shader or some process when building an atlas? Does that means use Alpha multiply instead of alpha blend when rendering ?

    Thanks in advance.
     
  7. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi ShawnMcCool,

    You should make sure the collision box didn't exceed your camera's near clip plane.
     
  8. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    [SOLVED - solution below]

    Sorry, I'm an experienced programmer but I'm very new to Unity and am working on doing things the right way instead of just hacking things up.

    I have attached a script to an ex2D sprite object. The script has the following code:

    On play I'm getting the error:

    What am I missing? i'm so close to having this stuff implemented.



    -- SOLUTION --

    I declared the type with:

     
    Last edited: Dec 27, 2011
  9. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    I've been playing with the system all day and I feel quite competent with the toolkit, now. Quick performance question. I have a sprite that is instantiated, it has a script that leads it from waypoint to waypoint in a grid. Then, the game object is destroyed when it reaches the final waypoint. I'm getting ~ 19 fps in game mode as shown in the image below. Is this indicative of a performance problem?

    Each grid tile is also a sprite.

     
  10. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi ShawnMcCool,

    Based on your Draw Calls, your sprites are well organized so it is not rendering cause the performance down. You can start a Unity Profile see what happen behind your scripts.

    Things may cause fps drop down such as keep calling Instantiate() during update.
     
  11. CapnCromulent

    CapnCromulent

    Joined:
    Sep 7, 2010
    Posts:
    45
    Hi jwu,

    How are the custom editors for SpriteBorder and SpriteFont defined? I'm creating my own subclasses to handle retina display, but I can't find anything to inherit from (and neither exSpriteEditor nor exSpriteBaseEditor work).
     
  12. michaelkamms

    michaelkamms

    Joined:
    Nov 21, 2011
    Posts:
    7
    Hi,

    1. Create a new Project, new Scene.

    2. Add an exSprite Object to the Scene. Assign Texture, test Play, everything ok.

    3. Add a new C# script file, with following code:

    void Start () {
    exSprite sp = (exSprite) gameObject.GetComponent("exSprite");
    sp.HFlip();
    }

    4. Assign this script to the exSprite GameObject created in step 2 above.

    5. Test play, it doesn't Flip? Anything missing??

    If I add this:

    void Start () {
    exSprite sp = (exSprite) gameObject.GetComponent("exSprite");
    sp.HFlip();
    sp.width = sp.width + 1;
    }

    and it will Flip.

    May I know what is missing?

    Thanks
     
  13. Boud

    Boud

    Joined:
    Dec 5, 2009
    Posts:
    13
    Hi jwu,

    Any plans to make ex2D compatible with the flash export of the beta vesion 3.5 ?
     
    Last edited: Jan 2, 2012
  14. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi CapnCromulent,

    We didn't public the editor of exSpriteBorder and exSpriteFont, I think I can just public them in next version or the next daily build.
     
  15. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi michaelkamms ,

    Nice catch!! This is a bug. I've fix it. Will released in the daily build and the next version.
     
  16. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi Bound,

    Not yet, we test 3.5 and the flash didn't support Generic codes (List<T> actually). Sad....
     
  17. Boud

    Boud

    Joined:
    Dec 5, 2009
    Posts:
    13
    Oh that's too bad, generics are really convenient and doing without them means a lot of duplicated code :(
    I guess there's no hope to see ex2D work with the flash export, unless it handles this or you build a version without generics (with is costly and maybe not worth it).

    Thanks for the response.
     
  18. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi,

    I'm looking forward to getting ex2D but have some doubts about using it. Sorry if this questions are not related to ex2D itself. Does it support different resolutions? (non retina/retina?). how would I handle collisions of sprites, I mean, I have used unity physic system for this but it seems to be eating a lot of cpu, Is there anything ex2D can offer to improve this part of unity? I need slope support in my game too.

    Thanks in advance.
     
  19. Gooms9

    Gooms9

    Joined:
    Dec 17, 2011
    Posts:
    31
    Hey, great tool. Is there any ETA on the tile map editor? Or is there any way to get a pre-release version or something? Really want to integrate with ex2D on our project starting ASAP, but being held up a bit by the lack of proper tile map editors.
     
  20. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    I had several structures which used Generic types, in my case I found a workaround, maybe you could try it out also.

    Instead of using generic types, I am declaring a Queue without the <T> and casting what I want from it when I dequeue or peek.

    For example,
    I used to have "private static Queue<GameObject> availableBricks;", now I have "private static Queue availableBricks;".
    Hence, before I had "temp = availableBricks.Dequeue ();" and now I have "temp = (GameObject) availableBricks.Dequeue ();".

    I do not know if the problem can be solved like I did in my scripts, but I am saying it here so it can be checked out.
    I still do not know in depth how many of the things I use work (we are rushing heads in on a project), so the issue may be more complex than I guess.


    I hope it can help somehow
    And sorry for my possibly weird english :p


    Fernando.
     
  21. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    You sure about that? I'm using List<T> all over the place in NGUI and it runs fine in Flash. Flash didn't support Stack<T> as I recall, but List works fine.
     
  22. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    Unfortunately, he is right.

    I use ex2d in a project of mine and, when trying to export it to flash, it complains about generics lists being used by exSpriteAnimClip.

    Here is what it says:

     
  23. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    No that's an error about how it's used, not about the list itself. I noticed flash export doesn't support some things, like string.Equals(a, b), for example. In this case the culprit would be BinarySearch.
     
  24. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    Thanks for sharing that info, it is good to know!
    Do you have any idea on how to "correct" (maybe "port" would be better) that piece of code?
     
  25. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Can't say I've ever used a BinarySearch function... simplest solution? Write a search function yourself like so:
    Code (csharp):
    1. foreach (T entry in list) if (entry == expected) return entry;
     
  26. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    I just purchased ex2D - my very first question relates to NGUI. Can NGUI use the atlas and the atlas info generated by ex2D? So I don't need to get TexturePacker too.

    Thanks,
    Gyula
     
  27. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Er, more a question for the NGUI thread then...

    Technically you don't need the TexturePacker, it's just a little more convenient if you do. You can also use the free version without having to buy it.

    In regards to your question though -- although I am not familiar with ex2D, the short answer would be "not fully". If ex2D uses a texture atlas you could, technically reuse the same exact texture atlas for NGUI -- you will just have to define your sprite rectangles when creating your UIAtlas as you add new sprites.
     
  28. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi Hexdump,

    We didn't support different resolution in v1.2 yet. We may doing this after v1.3, but it is complex for multiple resolution support and need more testing. So it won't be released quickly I doubt.

    ex2D currently support Unity's physic system, we didn't provide 2D collision solution yet. But we are going to add custom collision shape in editor. After that, we may schedule some research on a faster collision detection algorithm fit for 2D games.

    Regards,
    Wu
     
  29. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi Gooms9,

    We currently hang on all new features: TileMap Editor, Custom Physics Editor, Skeleton Animation Editor and start focusing in solving problem in the new structure and will be released in v1.3. The new structure will avoid crashes when export and import image in atlas and will no need for rebuild prefab and scenes when atlas changes. Also it will solve the problem in team working.

    Since the v1.3 have big changes in structure, we not sure the v1.2 can compatible perfectly. We will try to build some script to help user convert current project from v1.2 to v1.3. But no guarantee on everything, so if you are in the middle of a project using v1.2, we will recommend you continue using it and just download our v1.2 mini fix updates. If you are trying to start a new project now, may be you can wait and see our v1.3 progress after January.
     
  30. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi fgielow,

    The red text below is dead.

    Thanks for the advice. Actually if u3d can't solve the Generic problem. I think I can still write my own data structure instead of List<T> and Dictionary<T>. Then put them in those script used it and use Macro #if #else to choose the proper one.

    The thing is generic structure means no cast from types such as Object and that can save some performance. But it takes a lot of work, and I may try it when I got the time.


    The red text above is dead.

    Just like the ArenMook said, I can try to rewrite those generic function not supported by Unity3D 3.5. (The thing is I must find a PC install 3.5 first)
     
    Last edited: Jan 4, 2012
  31. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Yeah, I agree. since ex2D provide the atlas information and everything it needs, I think it is easy for user to transfer data between two plugins.
     
  32. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi ArenMook,

    Nice advice. We just receive the reports from user about flash export error. Based on the error message and your experience, I think you are right. I have to find a machine install the 3.5 and try it myself.

    Thanks for sharing and we will see what we can do to make flash export works!
     
  33. Boud

    Boud

    Joined:
    Dec 5, 2009
    Posts:
    13
    Good news, hope you can get to it and good luck with the refactoring ! Flash Support would be a real neat addition to the features of ex2D !
     
  34. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    Yes, I was thinking where to ask... Thanks for the clarification.
     
  35. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi jwu

    There are a lot of pictures like window parts in Textures->GUI->components of ex2d.
    I visit your web site I think it is SpriteBorder Component's parts.
    But, there aren't sample Scene in the project.
    Is there the document how to use it?
     
  36. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi Shinriyo,

    Sure, the document is here: http://www.ex-dev.com/ex2d/wiki/doku.php?id=manual:create_sprite_border

    These textures are belongs to exSpriteBorder. And I think there have a sample (a scroll view window) that use the sprite border to illustrate how to do it. Check them first and ask me if you have further problem.
     
  37. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Hi,

    Could you suggest me the best approach to use ex2D as GUI rendering engine for a 3D game? (like which kind of camera I have to use, best options and such) Thank you!
     
  38. CapnCromulent

    CapnCromulent

    Joined:
    Sep 7, 2010
    Posts:
    45
    There's a lot of information in the Unity reference manual about using cameras, and you should start there first.

    Assuming you want a 2D GUI that's independent of your 3D elements:
    1. Create a second camera and set its projection to Orthographic.
    2. Set the size of the ortho camera to 0.5f * Screen.height. Your sprites can now be positioned in pixels.
    3. Create a new layer for your GUI elements.
    4. Set the Culling Mask of the orthographic camera to include just your GUI layer; conversely, set the Culling Mask of your main camera to include everything else.
    5. Set the depth of the ortho cam to 0, and set the depth of the main camera to -1. Larger depths render in front of lower ones.
    6. Set the Render Camera parameter of your new sprites to the ortho cam.
     
    Last edited: Jan 6, 2012
  39. CapnCromulent

    CapnCromulent

    Joined:
    Sep 7, 2010
    Posts:
    45
    Hi Jwu,

    I'm testing out the daily fix build 120103, which gives me access to the editor components (thanks!), but now all my sprites are no longer visible unless I disable pixelperfect. I'm not using the layer system and am relying on Z-ordering, if that makes a difference.

    GitHub doesn't reflect the latest changes, so can you tell me what changed from 111225 in regards to PixelPerfect calculations?
     
  40. KaelLiu

    KaelLiu

    Joined:
    Jan 7, 2012
    Posts:
    1
    nice post man
     
  41. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    Hi jwu!

    I'm gonna buy ex2D because it looks like the best 2D solution currently

    I'm confused what i gonna miss if i buy from your website instead of the Unity Asset Store ?

    Do i get access to daily builds and new updates the same way or is there any thing different, depending on the method of purchase ?

    EDIT:
    bit the bullet and bought directly from your webstore anyways.. but still would be interested if there are any differences betwen the Asset Store and the direct webshop buys ...
     
    Last edited: Jan 8, 2012
  42. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi sebas77,

    For 3D game, you have two choice:

    1. render the gui that share the same camera as your 3D scene. That means you are using perspective camera (properly the main camera) and make all sprites/text in ex2D as Pixel-Perfect. also make sure they are billboard (you'd better get the daily fix version after 120103, which fixed pixel-perfect camera problem when working with perspective camera )

    2. you can create another camera that just render the UI stuff. You can set this camera to orthographic and do the rest of things as you wish.

    I prefer method 2 cause it is easy and less problem.
     
  43. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi CapnCromulent,

    I've submit the latest changes to github. Check it first.
    About the pixel-perfect changes, what I do is: instead of changing the sprite.scale, I calculate the pixel-perfect changes in the new variable sprite.ppfScale. So if you are handling things in a old scene, you'd better make them at least calculate once to update the size.

    And the sprite's final scale equals to scale * ppfScale. If user don't enable pixel-perfect option in sprite, the ppfScale will reset to 1. The reason I add ppfScale is because in sometimes even you are in Pixel-Perfect you still want to do some animation effect to text. This is very common in a 3D game when player or enemy get damage and want to show a damage text. The text may have a punch curve for scaling but stay in pixel-perfect size in 3D scene.

    Hope this help you correct things.
     
  44. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi spacefrog,

    I've contact our sales (natas) to answer the question in details. In short, they are the same.
     
  45. nantas

    nantas

    Joined:
    Feb 11, 2010
    Posts:
    124
    Hey spacefrog,

    There's actually no difference for user whether you buy it from Asset Store or our web store. If you buy from our web store you will be prompt to subscribe to our mailing list so you can receive Daily Fix Build automatically later on.

    If you buy it from Asset Store, you can still subscribe to our mailing list and get access to our other products promotion ( like discount when buying ex2d pro). From a user experience point of view Asset Store may be better, but our web store can have different kinds of promotion and discount.
     
  46. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hello All,

    We just make ex2D support Unity3D 3.5 and Flash Export!!!!!

    I'm glad to let you guys know, I just modify the ex2D to make it fit the Unity3D 3.5 beta, and the ex2D successfully exported flash build!

    We just post our effort in our blog here: http://abitgames.com/2012/blog/unity3-5-support-coming/

    If you already bought ex2D and subscribe our newsletter, you will receive the daily fix including 3.5 support very soon! Cheers!!
     
    Last edited: Jan 8, 2012
  47. CapnCromulent

    CapnCromulent

    Joined:
    Sep 7, 2010
    Posts:
    45
    Hi Jwu,

    So, I think I've figured out the problem. Before, I had been setting my orthographic camera's height to 0.5 so that I could position items relative to the viewport for retina displays, and as a result the pixel perfect sprite scale tended to be really small (0.03125 for 320 pixel displays).

    The new version of ex2D seems to want this scale set to 1.0, and unlike the old system, the scale doesn't recalculate the values when I toggle pixel perfect. Is that intentional?

    I guess if this is the way things will work in the future, I'll have to write a script to process all my sprites, but for the time being, I'm going to stick with 1.2.2
     
  48. WillBellJr

    WillBellJr

    Joined:
    Apr 10, 2009
    Posts:
    394

    Well unless I'm wrong, buying from the asset store is a tad more expensive (UT gets a cut), buying directly saves that overhead.

    I typically prefer to buy from the Asset Store because it then provides me a one stop shop for adding all my >3rd party components< to my projects without having to hunt for them in my saved downloads - guarantees that I have the latest versions when I install them as well.

    In fact I'm wondering how I can get my old component purchases (EZGUI for example) to become accessible from the Asset Store??

    I just prefer the convenience of importing all of my Unity assets though the store now instead of manually importing packages...

    -Will
     
  49. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Hi,

    I have two questions here:

    1) Since we installed the ex2D Package, we cannot use monodevelop to compile anymore. This is quite annoying and I would like to know if you share the same problem.

    2) Am I supposed or can I inherit from exScreenPosition? The problem is that once I do it, the new component shows the exScreenPosition properties in a wrong way (the values are correct, is the way they are shown that looks wrong).
     
  50. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    For me it is compiling... 3.4.2, OS X Lion, with the latest Ex2D...