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

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

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

  1. vpin

    vpin

    Joined:
    Mar 15, 2012
    Posts:
    19
    Hi, jwu.

    I have a problem- periodically resets the flag - "Read/Write Enabled" on my atlas.
    It usually occurs after the opening scene, when it changed a different developer.
    I have several atlases - very annoying always include these flags.

    Best regards.
     
  2. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Hi, I'm trying to do the dynamic atlas build by script, i tried the script from earlier post
    http://forum.unity3d.com/threads/101811-ex2D-the-best-2D-sprite-solution-for-Unity-RELEASED?p=671437&viewfull=1#post671437

    I got a lot of error messages, is it only working with older verion and not compatible with newest version of ex2D?

    Actually i just need the Atlas Build function, so i removed all the CreateAnimClips codes. Finally I got single line of error:

    Assets/AutoPipeline.cs(79,9): error CS0246: The type or namespace name `exAtlasInfo' could not be found. Are you missing a using directive or an assembly reference?

    Btw, I tried the script from wiki also http://www.ex-dev.com/ex2d/wiki/doku.php?id=manual:advance:create_assets_by_script, and I got the same error.

    The error have something to do "exAtlasInfo", any idea?

    Do you have an updated and working example code for create atlas by script?

    I'm using ex2D 1.2.5, unity pro 3.5.2f2 on MacOSX Lion
     
  3. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Hi jwu,

    Does ex2D compatible with Flash build?

    After I installed the ex2D, even a simple scene ( just a Main Camera, Sphere, Directional light) and I can Not build the Flash SWF.

    I'm using ex2D 1.2.5, unity pro 3.5.2f2 on MacOSX Lion
     
  4. jdviz

    jdviz

    Joined:
    Nov 3, 2008
    Posts:
    35
    How? Where? Is there a demo? Tutorial? Documentation? I need to be able to do it, but I don't know how?
     
  5. johnny_karas

    johnny_karas

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

    Because spriteAnim.Play(name) will rewind the animation and play it from start. So you can not do this in Update every frame. If you wish, you can simply do it as

    Code (csharp):
    1.  
    2. if ( spriteAnim.IsPlaying("run") == false )
    3.     spriteAnim.Play("run");
    4.  
     
  6. johnny_karas

    johnny_karas

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

    This problem should relate with the PostImportProcessor. I think when others open the project and ex2D detects the changes and then it will re-import some atlas and apply the default setting of it. I doubt I should design the texture info including atlas settings in ex2D v2.0 to completely solve the problem.

    I'm not sure if I guess the right thing and the right issue, can you explain more so that I can help to reproduce the problem locally.
     
  7. johnny_karas

    johnny_karas

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

    The problem is you running the script in Runtime not in Editor. Please put the script to Editor folder so that the exAtlasInfo can be import. Because create atlas is an Editor operation, you can't do it in the Runtime.
     
  8. johnny_karas

    johnny_karas

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

    We currently provide Flash build by Email request. Because I only do limit support to Flash version, it is not fully tested but only compile successfully and can export project to Flash. (performance and picture quality not tested yet).

    You can send E-Mail asking a Flash build version. ==> KarasAya[at]gmail.com
     
  9. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi JD-,

    There is lots of way in implement HUD. For a 3D game, you can put your sprite in the very front layer or writing a shader with the Overlay+1 queue.

    After that you can calculate the screen position to put your sprite at the right place, or you can just put your sprite under your camera as child node and place it in a proper offset.

    Then you can add collision box to your sprite and let them respond the touch/mouse cick script. If you just want to show some status of your game, write a script and grab the info and put it in the scene.

    You also can use 2nd camera which will render the HUD sprites in a different pass, and just put the depth order higher than the first camera.

    All this documentation can be found in Unity's Web Site, they are just part of Unity3D, ex2D here do nothing but show the sprite.
     
  10. simjeanny88

    simjeanny88

    Joined:
    May 17, 2012
    Posts:
    19
    thank jwu! :)
     
  11. vpin

    vpin

    Joined:
    Mar 15, 2012
    Posts:
    19
    Yes, it seems to be true.
    Well, that will wait for new version.
     
  12. damienthorn

    damienthorn

    Joined:
    Oct 1, 2009
    Posts:
    28
    Is there going to be an update for the evaluation version in the near future?
     
  13. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33
    What about writing a editor script to update the atluses. i have same kind of problem but not with the atleses with the render camera
     
  14. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there,

    is there any (bool)method to check if a SpriteObject is flipped horizontally or vertically?
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Small bug with outline option for bitmap (retro) style fonts. If you use the scale parameter (within ex sprite font component) it will break the outline. I am not sure this is fixable, and it is a small issue for us anyway, we can always render another font out with outline.
     
  16. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey can this be used to design in game UI?
     
  17. aegget

    aegget

    Joined:
    May 10, 2012
    Posts:
    7
    Hello. I'm having problem with getting my characters walk animation to play
    (I got Unity version 3.5.2) Here is a part of my code:

    Code (csharp):
    1.  
    2. private var spriteAnim : exSpriteAnimation;
    3.  
    4.  
    5. function Start(){
    6. spriteAnim  = GetComponent("exSpriteAnimation");
    7.  
    8. }
    9.  
    10. function Update(){
    11.  
    12.     if(pcOn == true){
    13.    
    14.         if(grounded == true){
    15.        
    16.         // MOVEMENT CONTROLLS | SET TO [ D-PAD ]
    17.         var fwrdAmt = - pSpeed * Input.GetAxis("Horizontal") * Time.smoothDeltaTime;
    18.  
    19.         if(pRotation == 0){ //if character is facing 0 degrees
    20.         transform.Translate(Vector3.right * fwrdAmt); //move forward
    21.            
    22.             //play walk animation
    23.             if(spriteAnim.IsPlaying("MainChar_Walk") == false ){
    24.             spriteAnim.Play ( "MainChar_Walk" );}
    25.                                        
    26.         }else if(pRotation == 180){ //if character is facing 180 degrees
    27.         transform.Translate(Vector3.left * fwrdAmt);} //turn and move other the way
    28.            
    29.             //play walk animation
    30.             if(spriteAnim.IsPlaying("MainChar_Walk") == false ){
    31.             spriteAnim.Play ( "MainChar_Walk" );}
    32.         }
    33.        
    34.        
    35.         // GET PLAYER ROTATION
    36.         if(fwrdAmt > 0){
    37.             pRotation = 0;
    38.            
    39.         }else if(fwrdAmt < 0){
    40.             pRotation = 180;
    41.         }
    42.  
    43.         // ROTATES THE CHARACTER ON Y AXIS
    44.         if(pRotation == 0){
    45.         transform.eulerAngles = Vector3(0,0,0);
    46.        
    47.         }else if(pRotation == 180){
    48.         transform.eulerAngles = Vector3(0,180,0);
    49.         }
    50.     }              
    51. }
    52.  
    Thanks
     
  18. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    How do you play animations in a queue? The standard animation.PlayQueue() doesn't work.
     
  19. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    How do I make an editor script which changes the colour component of an exSprite? I can do it but when I press play, the colour reverts to whatever it was before.

    I need to do this in the editor because I want to change the colour of a large number of exSprites at the same time as part of the workflow (not at runtime).
     
  20. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    You may need to call EditorUtility.SetDirty on the sprites. This works for me for my automated workflow (importing pngs into an atlas and making a bunch of sprites based on XML data)

    http://unity3d.com/support/documentation/ScriptReference/EditorUtility.SetDirty.html
     
  21. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I'm going to update it this week. Sorry, there's too much work last week.
     
  22. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Code (csharp):
    1.  
    2. sprite.scale.x < 0 is hflipped
    3. sprite.scale.y < 0 is vflipped
    4.  
    I should add two function wrap this, cause too many people asking it.
     
  23. johnny_karas

    johnny_karas

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

    The outline function actually is used for prototype and it is not work well with scale sprites. I think when you confirm the outline style, a better way is make an bitmap font resources with outline naturally.
     
  24. johnny_karas

    johnny_karas

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

    Sure, we use it as GUI in our game, and I will release our GUI framework based on ex2D two weeks later.
     
  25. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thank you! I'm quite new to editor scripts and didn't realise this. It helped a lot :)

    Hi hippocoder,

    Yep I agree and is faster to execute.
     
  26. johnny_karas

    johnny_karas

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

    Can you tell me what's the problem when use this code, can't judge it by reading.

    Basically what you are doing is not a well designed animation system. For control character animation playing, I prefer use state machine. If you don't have one, here is mine, you can grab it from github and use it: https://github.com/jwu/exUnity/tree/master/FSM
     
  27. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    There is no PlayQueue() interface in exSpriteAnimation. You just play another one by checking the first one finished.
     
  28. Bertrand07

    Bertrand07

    Joined:
    May 21, 2012
    Posts:
    5
    Hi
    I'm trying to make a score display for my game.
    So i have created a SpriteFont object. When i complete the text field manually in the inspector, that work fine.
    But i need to change the text by script.
    I put a script component on this SpriteFont object.
    This is the code inside the script:
    JavaScript:

    Code (csharp):
    1. #pragma strict
    2.  
    3. function FixedUptade()
    4.     {
    5.     var sampleText:exSpriteFont = gameObject.GetComponent(exSpriteFont);
    6.     sampleText.text = "This is a test. Test. Test. Test.";
    7.     }

    I have find this code in this forum.
    But that doesn't work. Nothing happen.
    Can you say me what i'm doing wrong?

    Thank you!
     
  29. Racoonacoon

    Racoonacoon

    Joined:
    May 21, 2012
    Posts:
    1
    Ex2D seems like it is pretty nice, but the documentation is grossly lacking. It is irritating to be forced to search through pages of forum posts to try and find what I need. It is bit of a time sink :(

    I'm currently interested in the scripting side of ex2D, but there isn't enough documentation out there for me to wrap my head around the exLayer, exLayer2D, and exLayerMng components. Would someone be kind enough to explain the proper usage of each of these?

    I'm also not really clear on the differences between a dynamic, abstract and normal layer in regard to the layer manager. Could someone clear things up for me please?

    My main goal is to create sprites dynamically in such a way that the most recent sprite always overlays other sprites. With sprite manager it is a fairly trivial modification with the SetDrawLayer function, but it doesn't seem quite as obvious with ex2D.
     
  30. johnny_karas

    johnny_karas

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

    I can't find anything wrong in this script except if you have some physics settings that makes FixedUpdate not working. You can try put this in Update or maybe you can Debug.Log() see if the function is invoked.

    If it still not working, please send me E-Mail with a simple package including this problem.
     
  31. johnny_karas

    johnny_karas

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

    Yes the document of layer manager is a little bit old, I'm going to update all of this after the GUI framework released. (Right now is too busy in this feature).

    Let me explain a little bit:


    Yes, the documentation of layer manager is still lacking. I'm too busy to update the document, will be added recently.

    Let me explain the difference of normal, abstract and dynamic.

    Generally the normal is for static object, those objects when you put them in the scene you wish you don't want to change their depth. So the normal layer is for background and not delete/added objects. When you change the order or delete item or added item in normal layer, you will change the whole layer structure which cause the depth changes for all objects.

    The dynamic layer actually is what you want for those dynamically spawn/delete objects. When you set a layer to dynamic, you will see a value to fill. That is the depth block you wish to arrange for the layer. For example if you set the number to 200, it means you have 200 depth for all object in this layer. In this time, when you insert 2 objects in it, the object one will be dynLayer.z + 200/2, object two will be dynLayer.z + 200. Since the block is always 200, it won't affect the layer in front/behind it.

    The abstract layer is a layer that when object insert to it, they will have the same z that equals to the abstract layer's z.

    Hope these information help you. Any problem, let me know.

    And there is a discussion in how to use it here: http://forum.unity3d.com/threads/101811-ex2D-the-best-2D-sprite-solution-for-Unity-RELEASED?p=878025&viewfull=1#post878025

    BTW: the exLayer2D is deprecated, don't use it at all.

    I think exLayerMng is advance than SetDrawLayer, it gives you a way that can really organize the layer to prevent batch rendering break up and other issues. To dynamically adding a layer, you just need to setup a base layer, and write

    Code (csharp):
    1.  
    2. myLayer.parent = baseLayer;
    3.  
    The tips here is you can always create several baseLayer that have nothing but a pure GameObject, it makes you very easy to organize a scene. You also can prefab an object that with predefined layer on it. So every time you drag this object to the layermng, it will follow the order your prefab set it.
     
  32. Bertrand07

    Bertrand07

    Joined:
    May 21, 2012
    Posts:
    5

    Hi
    thank you for your answer.
    You was right, FixedUptade or just Uptade didn't was invoked. I don't know why actually.
    i recreate object and script, and now that work.

    Sorry for that.
    And thank you for your great and usefull asset!
     
  33. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there, i want to stop my animation at a certain frame.

    I have a simple animation:

    Code (csharp):
    1. if (!spAnim.IsPlaying("Move"))
    2.             {
    3.                 spAnim.Stop();
    4.             }
    I want to stop the animation also at a certain point/at a certain frame.
    The animation should play to that certain frame and then it should stop. How can i accomplish that?
     
  34. johnny_karas

    johnny_karas

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

    You have two way to achieve this. You can put an event in the sprite animation editor for this sprite animation in the frame you wish to stop, then when the animation triggered, you write your Stop code.

    You also can use GetCurFrameInfo function get the exSpriteAnimClip.FrameInfo. In the frame info it have the index and any other things that help you know the exactly frame and time you wish to stop the animation.

    Regards,
    Wu
     
  35. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's FixedUpdate and Update. Not Uptade.
     
  36. Harter

    Harter

    Joined:
    Feb 28, 2012
    Posts:
    119
    Hi jwu!

    Is it possible to set 'Static' checkbox for exSprite object? 'cause every time I click 'Play' button in the editor it disappear.
     
    Last edited: May 23, 2012
  37. bryantdrewjones

    bryantdrewjones

    Joined:
    Aug 29, 2011
    Posts:
    147
    Hi jwu :)

    Any time I have a scene file with a pixel perfect sprite or spritefont in it, Unity always asks me if I want to save the scene before closing it, even if I haven't made any changes. I'm guessing this is because ex2D is making some changes to the scene, perhaps something to do with the sprite scales?

    This isn't a big issue, but it's definitely annoying when I'm switching between scenes often :)
     
  38. johnny_karas

    johnny_karas

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

    What do you mean?
     
  39. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I've already suffer this from not only ex2D plugin, but others. Since ex2D use the [ExecuteInEditor] for some script, it makes it very hard to find out which script changes the properties. In ex2D v2.0, I update sprite and other component without [ExecuteInEditor], currently it works, but I need more test of this.
     
  40. Harter

    Harter

    Joined:
    Feb 28, 2012
    Posts:
    119
    I'm sorry for my bad English.


    When it checked sprite disappears (by pressing 'Play' button).

    upd. It happens ONLY if "Use Pixel Perfect" checked.
     
    Last edited: May 24, 2012
  41. bryantdrewjones

    bryantdrewjones

    Joined:
    Aug 29, 2011
    Posts:
    147
    Thanks for the quick response, jwu! I'm looking forward to 2.0 :)
     
  42. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Ok, I'll go check this and try to fix it asap.

    == Update ==

    Hi Harter,

    I've check this in my computer, but nothing wrong with Static + PixelPerfect. The sprite didn't disappeared. Can you send me an example for this?
     
    Last edited: May 27, 2012
  43. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
  44. Harter

    Harter

    Joined:
    Feb 28, 2012
    Posts:
    119
    It's my fault. I forget to replace ex2D with last daily fix build. Sorry and thanks.
     
  45. bryantdrewjones

    bryantdrewjones

    Joined:
    Aug 29, 2011
    Posts:
    147
    I'm playing around with using pixel art in my game, and I'm noticing that the pixels jitter whenever I move the camera or change the camera's aspect ratio. It seems that some pixels are becoming thicker or thinner than others.

    I'm using the same texture import settings described in this blog post. Has anyone else experienced the same problem? There was a guy in the comment thread from that article who also brought up the jitter....
     
  46. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    Hello guys, I like the updates on this forum and on the libs itself a lot, but I would like to ask you to update the docs (http://www.ex-dev.com/ex2d/wiki/doku.php) and add more to them (they are a very useful resource for any toolkit).
    Sorry if this may sound rude, did not mean it this way.

    Keep up the great work ex2D team :).
     
  47. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Bug (but I made a utility to fix it):


    #pragma strict

    Code (csharp):
    1. @MenuItem ("The Other Brothers Utilities/Fix wrong sprite size")
    2. static function FixAtlas()
    3. {
    4.     var spriteList:exSprite[] = FindObjectsOfType(exSprite) as exSprite[];
    5.     for (var s:exSprite in spriteList)
    6.     {
    7.         s.customSize = true;
    8.         s.customSize = false;
    9.         s.Commit();
    10.         EditorUtility.SetDirty(s);        
    11.     }
    12. }
    probably some redundant code but it does the job. What happens is when the atlas is updated, often it will make some sprites completely the wrong size. By toggling custom size, it will work as expected. This behaviour of ex2D was very fustrating and forced us to try all sorts of things like rebuilding and synching, none of which worked until I made that script.

    I leave it here for reference for others.
     
  48. johnny_karas

    johnny_karas

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

    I'm working on the new version of ex2D (v2.0), and the structure and functions are quite different than v1.+, I guess I have to leave the ex2D v1.+ documentation and start another wiki for v2.0. The thing is I can't do this until the whole v2.0 finished and been full tested. So please wait for it.
     
  49. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    Hey there jwu,

    I have something that is annoying the hell out of me for quite a while now. Let's say I have created an atlas and create several "Levels/Scenes" that uses the same atlas and I change a sprite in photoshop to change it's appearance. Once I get back to Unity it will automatically update (which is nice and good). However, it very often screws up other sprites. Even in other scenes for no reason. It's almost like there is a "cache" issue or such. Secondly, I am working with a "Team License" and we found out that even though I see it "screwed up" on my end doesn't mean that other team members see it that way. Is this a local cache/refresh issue?

    Thomas P.
     
  50. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi Thomas Pasieka,

    This is a known issue in ex2D v1.+. When you update the atlas, ex2D can only rebuild the atlas and rebuild the scene sprites for current opening scene. When you change the scene to other one, you have to run Edit/ex2D/Rebuild Scene Sprites from the main menu first to correct the scene. Also, if you make sprite to prefab, you'd better run Edit/ex2D/Rebuild Prefabs so that the prefab will update to the new atlas.

    We find this problem can be solved if the item of the scene is using prefab instead. But the key to solve the problem is change some of the structure in ex2D, that is exactly what I'm trying to do right now in ex2D v2.0.

    Let me know if my suggestion fix it temporary.