Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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 bdjones,

    I'll confirmed this first.
     
  2. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi,I have new problem when I just buy a license.

    I created a new project and import two ex2d package,and then imported my old project which with some prefabs in it,the prefabs are created with exSprite or exSpriteAnimation.
    Now all ex components are missing, u3d will crash when run button clicked,so I drag exSprite class to the missing point.
    At last,a part of prefab can run in scene,others can't.

    What is the best solution for me to update ex2d in my project? Must I made new objects instead of old?
    --------------


    oh,I just found it: edit->ex2d-> rebuild prefabs
    ??

    -------
    Now I found the reason why u3d crashes, script in exAnimation file are missing.
    So what's the fastest apply when I updated ex2d?
    Thanks.
     
    Last edited: Apr 13, 2012
  3. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    Thank you very much, that solved it. :D
     
  4. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Hi, I just started using ex2d so forgive me if this is a silly question.
    I am assembling a simple platform game and I am adding the ability to climb ladders.
    I created the climb animation, but how can I play it only while the player is pressing the up or down keys?
    Thanks!
     
  5. geno

    geno

    Joined:
    Mar 11, 2012
    Posts:
    18
    Hi harlock1975, this should point you into the right direction:
    http://www.ex-dev.com/ex2d/wiki/doku.php?id=ref:sprite_animation_scripting
     
  6. Evil_Toaster

    Evil_Toaster

    Joined:
    Apr 12, 2012
    Posts:
    10
    Howsit, I'm new to ex2D, and have been having trouble with updating atlases. If I create an atlas, and put say, 5 images into it, then put them on some sprites or prefabs, all is well. If I then add some more images to that same atlas, click to rearrange, then click build, the existing sprites / prefabs sometimes lose their image references. I go to the sprite, and select a new image for it, it remains blank. Even creating a new sprite from scratch doesn't work. The last time it happened I fixed it by recreating the atlas from scratch. I'd quite like to avoid having to do that each time I need to edit an atlas. At a guess, the problem seems to lie with the atlas not updating correctly.

    Is there something I'm meant to be doing to get this to work correctly?

    If this question has been answered previously, please can you refer me to the post / relevant documentation?

    On a different note, do you have any suggestions/guidance on how one could do polygon colliders on ex2D sprites, and do you plan to add support for them at some point?
    So far, the only two references I've found relating to this are:
    2D Toolkit: http://unikronsoftware.com/2dtoolkit/doc/tutorial/Creating_polygon_colliders.html
    Create in Maya then import to Unity: http://www.rocket5studios.com/tutorials/creating-2d-games-with-unity3d-part-5-complex-collision/
     
    Last edited: Apr 13, 2012
  7. geno

    geno

    Joined:
    Mar 11, 2012
    Posts:
    18
    There's a function for your out-of-sync problem for sprites. Go to menu: edit > ex2D > Rebuild Scene Sprites.
    Afaik polygon colliders are not supported by ex2D at the moment.
     
  8. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    How to update ex2d with files correct?
    I have hundreds of file now,Do I must fix them one by one?

     
  9. master_first

    master_first

    Joined:
    Apr 4, 2012
    Posts:
    4
    Hi all,

    I'm using ex2D.
    I want to glow object when my mouse over it.
    Does anyone know a method??

    The way I think is
    - Duplicate object
    - Place behide
    - Scale
    - Change color
    but this way I don't know how to make it lighten than original (~ ~''
     
  10. Evil_Toaster

    Evil_Toaster

    Joined:
    Apr 12, 2012
    Posts:
    10
    Aha, cool, that looks way easier than rebuilding the atlas. :) I'll continue my quest for polygon colliders elsewhere. There's got to be some relatively easy way to create one and attach it to a graphical object...
     
  11. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi,
    I'm trying made unicode sprite font in unity, but chars never show if font info file has multiple pictures.

    I created .fnt file and some pngs by BMFont like below, and created 'Bitmap Font' with the fnt and clicked build.

    After that I drag Font file to SpriteFontObject's 'Font Info'. but whatever I type in 'Text' attribute,nothing happens.

    Did I missed something?




    http://www.ex-dev.com/ex2d/wiki/doku.php?id=manual:font_editor:create_atlas_font


    "Can't not create atlas font from a4, it has multiple page info.",then how to use font info file which has multiple pages ?

    About update ex2d action: while 1.10 to 1.11,update menu made nothing happens when clicked, Is that because of ex-dev.com had forbidden by Great FireWall?
     
    Last edited: Apr 15, 2012
  12. corey.agp

    corey.agp

    Joined:
    Mar 23, 2012
    Posts:
    18
    Hey jwu,
    How would I go about assigning the sprite to the 3D object? As soon as I attach a Sprite Animation component to my 3D model, the model gets replaced with a 2D sprite mesh.

    Also, once I get the animated texture applied to my model, will the programmers be able to use all the ex2D scripting on the 3D mesh? Any help would be greatly appreciated.

    Thanks,
     
  13. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Thanks geno! I overlooked that section of the docs.
    I tried with pause/resume and it sort of works. "sort of" because I planned to have a single animation for climbing up, to be played backwards when climbing down.
    So if I climb up and reach frame 8 of my climbing animation, and then start climbing down I'd like to start playing the animation from 7 down to 1.
    Is this feasible in any way?
    Thanks again!
     
  14. geno

    geno

    Joined:
    Mar 11, 2012
    Posts:
    18
    You're welcome :) It should be possible to do that with some extra work. You can get the current frame index of an animation. The Play() method has an overloaded method which allows to specify the start frame from where an animation should begin to play. I'd give that a try by defining two separate animations for climbing up and down. When the player decides to change the climbing direction just swap the played animations, but let the new animation start at the same frame index where the last animation left off. Both animatinos will have to have the same number of frames, of course. ;-)
    Hope that helps.
     
  15. johnny_karas

    johnny_karas

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

    I've check the problem in my computer. However, I can't reproduce it. The pixel-perfect font works well when I change the resolution. Could you send me a package that including this issue? Thanks in advance.
     
  16. johnny_karas

    johnny_karas

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

    There's not file or class named exAnimation. We only exSpriteAnimation. Do you mean that? And it never change the place or name since v1.2.0. So I guess you have to relink those missing classes.
     
  17. johnny_karas

    johnny_karas

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

    You can use edit->ex2d-> rebuild prefabs solve the prefabs problem when you updating your atlas.

    We didn't provide polygon collider yet. We plan to do it later this year.
     
  18. johnny_karas

    johnny_karas

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

    The multiple-page font didn't support yet. If you are using unicode font, I suggest you make it in one picture currently.
     
  19. johnny_karas

    johnny_karas

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

    I think I'm misunderstanding your question. What I mean is you can attache the exSpriteAnimation in a 3D object. But you can do anything for your 3D model with ex2D. There is no material or function support change sprite animation in a 3D model's texture.
     
  20. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi geno and harlock,

    I think you can use exSpriteAnimState.speed = -1; Which will play backward of the animation. To give it a try, you can script it as:

    Code (csharp):
    1.  
    2. spriteAnim.GetCurrentAnimation().speed = -1.0f;
    3.  
     
  21. corey.agp

    corey.agp

    Joined:
    Mar 23, 2012
    Posts:
    18
    Okay, so it seems it cannot be done with ex2D. What I was wanting to do is use ex2D's sprite animation features to control a texture assigned to a mesh. For example, I have a 3D character whose face is composed of hand painted texture maps. I could have many face maps for various mouth shapes and facial expressions and by using the animation features of ex2D I'd be able to create complex face animation sequences that would be applied to the characters 3D model. Almost like a much more robust AnimatedTextureUV.js. I'd love to see support or even a new product dedicated to this.

    Thanks again!
     
  22. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi jwu,
    I got it,thank you.
     
  23. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Well, I see. May be there have plugin try to solve this problem. But ex2D is focus on 2D based game so we didn't plan to achieve this which will break our 2D pipeline. Sorry about that.
     
  24. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33
    Attach Unity Animation and make animation that chang change color of the sprite with the time. (ExSprite > Color_.r/g/b/a) and make sure put tick on use animation helper on exsprite.

     
  25. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    currently i have 2 atlas in my game. one for iphone, one for ipad.

    now i wonder how i access a single atlas.

    my idea so far was:
    - find out what atlas i need
    - load atlas
    - set textures to the objects

    i found out how i can set a texture from an atlas but i did not manage to reference an atlas inside my code.

    exAtlas atlas_iphone;
    atlas_iphone = ...... what comes here? how can i reference a specific atlas? i tried gameobject.find but that did not work so far.


    edit: someone used Resources.Load("atlasname") but which of my 3 atlas files will this load? or do i need to somehow get all 3 files from the resources folder and assign them to each other in code? i am confused :p
     
    Last edited: Apr 16, 2012
  26. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33

    Just wondering, are u use 2 different atluses for qulity issues ???? like for iphone u use 1024 x 1024 atlus and for i pad you using 2048 x 2048 atlus that having same elements that iphone atlus have ??

    If so what i am doing is use only one atlus that is 2048 x 2048 after u buld atlus. select atlus image file and select Max Size as 1024 so then unity will resize ur atlus. when u porting to Ipad select atlus again resize to 2048 insize Unity.

    Actually this is what im doing. its seems much easyer than what u looking i think
     
  27. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    usually it ends in chaos if unity "automatically" resizes elements. i want pixel perfect graphics for all devices so more than one atlas seems to be a good solution. (because i can load a small atlas on an iphone 3gs to save memory, while on an ipad 2 i can load much more into memory)
     
  28. bryantdrewjones

    bryantdrewjones

    Joined:
    Aug 29, 2011
    Posts:
    147
    Thanks jwu! I sent an email to support@ex-dev.com :)
     
  29. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    I have a sprite prefab that needs to be pixel perfect. When it is instantiated I have to set the renderCamera before pixel perfect works. This creates an ugly error message that the camera is unset on instantiate of the object. The object is also NOT pixel-perfect until the camera is set so it looks wacky as it's loaded into the scene for a split-second.

    What should I do to handle this?
     
  30. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    sorry for the multiple questions...
    one thing i also cannot find out: can i creat a new exsprite from code? like creating a new one and assigning a texture/atlas to it.
     
  31. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Let me answer your two questions in one thread:

    1. You should load the exAtlas in your Resource.Load. But you should put your atlas, atlas texture, atlas material in Resource folder. But don't put the atlas - Editor Info in it (well you can but not recommended).

    2. Just create a exSprite prefab and instantiate the prefab.
     
  32. johnny_karas

    johnny_karas

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

    Nice catch!. I'll do more test and I think I should move some of the init code from Awake to Start, so people who instantiate it can set the value first, then in the end of this frame, the start will be invoked. I'll do more test and start a patch. I'll update this issue. Thanks to your report!
     
  33. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33
    ita not really automatically resize thing. i mention u need to, do set by ur self.
     
  34. master_first

    master_first

    Joined:
    Apr 4, 2012
    Posts:
    4
    Hi,

    Can I get pixel from Sprite Object (exSprite)?

    I want to check if the point I select is alpha color or not.
     
  35. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    @2: perfect. thanks :)

    @1: do i need to do more than one Resource.Load for my atlas or do i just do it once with the name? i am not 100% sure how all my atlas data will connect after the load itself.

    @everything: thanks so much for your constant helping. i am very happy with ex2d and the support :)
     
  36. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    If you get it working could you detail your findings in this thread for others to see your approach at this?
     
  37. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    i did not load the atlas from resources yet but here is how i load a specific atlas to change textures:

    1) i create an exSprite prefab with a texture that is in (for example) my ipad texture atlas.
    2) this prefab i put into the resources folder in unity (we do not want to have it in the scene unless we need it)
    3) usually my app loads the iphone 3g texture set (because it uses not much resources)
    4) in case i detect an ipad (for example) i:
    4a) load the ipad atlas from resources (this needs to be done yet, currently its in my project)
    4b) instantiate the prefab we created in 1)
    5) with the instantiate and the atlas loading i now have the atlas inside my hierarchy and can address it via the loaded prefab
    6) i cycle through all my sprites and change the textures with the ones from the (new) ipad atlas

    this way i do not need to load an atlas into memory if i don't need it. this (i think) saves me resources on older devices
     
  38. figbash

    figbash

    Joined:
    May 13, 2008
    Posts:
    60
    Does anyone have a good way to get the height/width of an exSpriteFont? I need to do some dynamic positioning of GUI elements next to sprite font objects that change size.
     
  39. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    To load the resource of atlas, just use Resource.Load ( "your/atlas/path/name.asset" ); and convert the object into exAtlas. You don't need to load all the things since Unity's Resource.Load function will automatically load resource with dependence. So here be careful on your sprite prefab. If the prefab have atlas referenced (the sprite texture setted), it will automatically load it. So you should create an empty sprite to operate the thing. Use sprite.SetSprite ( atlas, index ); once your resource loaded.
     
  40. johnny_karas

    johnny_karas

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

    You have to write the function by your self. You have to map your sprite into the atlas texture and get the pixel there. Also to make the pixel color readable, you have to enable the read/write settings in the atlas texture. ( they disable to save the CPU memory in runtime ).

    I put this feature in my backlog list and will implement it afterward.

    Here is the forum thread talking about it. http://forum.unity3d.com/threads/101811-ex2D-the-best-2D-sprite-solution-for-Unity-RELEASED?p=885463&viewfull=1#post885463
     
  41. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You can use exSpriteFont.boundingRect
     
  42. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Wow, I should def look at this to build my GUI for my game... :) And it is about time Unity had a 2d solution :)
     
  43. master_first

    master_first

    Joined:
    Apr 4, 2012
    Posts:
    4
    ^
    ^
    Thx jwu for your advice.

    I adapted your refer code for mine. I do not completely understand about "rotated" system.

    For now, it work like I want it to.
    It can check touch object with alpha chanel whatever the anchor and scale is. \0/
     
  44. nikitaanovikov

    nikitaanovikov

    Joined:
    Apr 17, 2012
    Posts:
    1
    Hello, I have some questions before buying ex2D components
    - are there any mouse (touches) handling features?
    - if no, do you have any tutorial to use that in your framework?
     
  45. figbash

    figbash

    Joined:
    May 13, 2008
    Posts:
    60
    Hi,
    I'm using boundingRect but variable doesn't seem to be updated until the next frame after you've changed the text. Is there anyway to force update it? I'm trying to change the text for a bunch of labels and then have them arrange next to each other in the same function, for instance:

    void UpdateLabels()
    {
    exSpriteFont label, label2;
    label.text = name;
    label2.transform.position.x = label.transform.position.x + label.boundingRect.width;
    }

    Edit: Nevermind, I found a solution. If anyone else is curious I simply did:

    MeshFilter meshFilter = labelName.GetComponent<MeshFilter>();
    labelName.ForceUpdateMesh(meshFilter.mesh);

    To force it to update before the next frame, and now boundingRect is correct.
     
    Last edited: Apr 18, 2012
  46. johnny_karas

    johnny_karas

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

    You can call spriteFont.Commit(); to get this value update. But that means you have to manage the performance by your own.
     
  47. johnny_karas

    johnny_karas

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

    - The unity3d provide MouseTouch functions, and you can use them in ex2D.
    - Currently we don't have tutorial for this, because Unity's official documentation already mentioned it.
    - We are developing a new GUI framework based on ex2D and will release it at the end of May.
     
  48. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    oh really? if it loads automatically i don't need to worry about loading anyways right?
     
  49. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    These are great news!
     
  50. JKL

    JKL

    Joined:
    Apr 19, 2012
    Posts:
    4
    If I purchase ex2d now, what's the upgrade policy when you release 2.0 next month?