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

    1) I will update the eval version for both 3.5.6 and 4.0.
    2) The animation editor will scale down the size of the sprite if the sprite exceed the preview window, so what do you mean it bogs down when sprite getting larger?
     
  2. johnny_karas

    johnny_karas

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

    Every time you call Play or PlayDefault, the animation will rewind and play from begin, so if you keep collide something, check the IsPlaying first before play it. The code looks like this:

    Code (csharp):
    1.  
    2. if ( xxx.IsPlaying() == false )
    3.    xxx.PlayDefault();
    4.  
     
  3. johnny_karas

    johnny_karas

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

    You can not change animClip.speed, because it is an Asset but not a Instance/State. Instead, you need to change the exSpriteAnimState. An example code would be:

    Code (csharp):
    1.  
    2. exSpriteAnimState animState = mySpAnim.GetAnimation("anim_name");
    3. animState.speed = your_speed;
    4.  
     
  4. soulburner

    soulburner

    Joined:
    Mar 25, 2012
    Posts:
    167
    Wu Jie, please assist me. I still have to use your atlases for fonts (I moved 90% of sprites to TexturePacker). And my atlas broke again (it broke about 20 times during all developement process).

    Now it is sometimes impossable to add new sprites... Sometimes this atlas is broken even after rebuild... I've tried to re-sync AtlasDB, but had no success.

    When I'm trying to invoke AssetDatabase:SaveAssets I get many of such errors:

     
  5. johnny_karas

    johnny_karas

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

    The problem is because the atlas didn't entirely remove the texture element. I don't know what did you do to the atlas data, it seems like the texture exits in the Atlas Editor Info, but the atlasDB didn't find it. You have to remove the wrong texture from the atlas EditorInfo so that atlasDB can link it. If you find no way to clean it, please try to use Debug Mode for the Inspector and click the atlas EditorInfo, you will find the incorrect texture.
     
  6. csotomon

    csotomon

    Joined:
    Apr 28, 2012
    Posts:
    20
    How can I make that a sprite use the lights and the fog of unity to create a maze atmosphere? I want to hide the sprites that are under the fog.
     
  7. Yasantha

    Yasantha

    Joined:
    Nov 29, 2012
    Posts:
    5
    Does ex2d Supports Unity 4 Yet ?
     
  8. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    The default ex2D shader didn't support fog mode (Fog {Mode Off}). If you want to use fog in your game, you should enable the Fog in SpriteBlend.shader. I'm not sure if there should have further effort for the shader to make Fog affect sprite. I search the document, and it looks like enable this in shader will be fine in Fix Render Pipeline.
     
  9. johnny_karas

    johnny_karas

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

    I will submit Unity 4 version of ex2D to Asset Store this weekend, sorry for the delay. You can ask me through E-Mail to get a quick one.
     
  10. raincole

    raincole

    Joined:
    Sep 14, 2012
    Posts:
    62
    Does ex2D have 2D particle system? If not, is there any best practice/tool to implement 2D particle effects?
     
  11. lancerfour

    lancerfour

    Joined:
    Feb 24, 2010
    Posts:
    24
    Hey, been using ex2d for a while now--it works great and I really enjoy using it--i was just wondering if you guys might ever get your own forum? This post is ridiculously long and really makes it impossible to find answers to any particular question. It'd also be nice to have a central area to house our ex-specific editor scripts and the like.

    Cheers, Tim
     
  12. fuzzysam

    fuzzysam

    Joined:
    Jul 6, 2012
    Posts:
    1
    Hi Wu Jie,

    I bought Ex2D a few days ago, I'm using it to show animations built up of a number of fairly large pngs arranged in a number of atlases. These animations all play from a single game object on the stage. This works fine on windows and on one of my iOS devices (an iPad 3) but on any other iOS device I test on, the app crashes immediately. Reducing the number of animations or removing the sprite object from the scene entirely seems to fix the problem, but I'm having difficulty understanding what is going wrong and therefore how to fix it.

    Do you have any suggestions at all or common mistakes that are made when setting up 2d objects that could cause an immediate crash?
     
  13. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello wu jie,
    i bought ex2d and was wondering if the atlas editor could export the coordinate of the picture in txt format, similar to texturepacker, if so that would be really awesome and universal as it could be also use outside of unity.

    cheers!
     
  14. MatrixBai

    MatrixBai

    Joined:
    Mar 19, 2012
    Posts:
    13
    Hi, Wu Jie,

    I got a problem with exSpriteAnimation. I used a PoolManager to preallocated objects for reusing. Everything is fine when PoolManager create and spawn new sprite animation object in same scene. So I set the PoolManager as global one, create it when game start, and don't destroy when load new scene. However when the sprite animation object playing the related sprite seems like don't change frame.

    After some investigation, I confirmed the animation is working, just the sprite did not show changes. And weird thing is after I select the animation object in Unity3D editor hierarchy, everything is going well. I'm not sure what's wrong with the animation object, maybe all of this lead by the PoolManager but it still can't explain the weird hierarchy thing. Have you met similar problem before?
     
  15. MatrixBai

    MatrixBai

    Joined:
    Mar 19, 2012
    Posts:
    13
    OK, after search this thread I found the solution, set the renderCamera to Camera.main. It seems like when a exSprite cross scenes, we should manual update the renderCamera.
     
  16. gabs

    gabs

    Joined:
    Sep 11, 2010
    Posts:
    39
    or:
    OnEnable()
    {
    sprite.Invoke("Awake", 0f);
    }

    A nasty workaround, I know. But it's this or having no animation with persistent sprites.
     
  17. gabs

    gabs

    Joined:
    Sep 11, 2010
    Posts:
    39
    Hi Wu Jie,

    I just made my project compatible for flash exporting, however there are two small incompatible things on ex2d part:
    Code (csharp):
    1.  Usage of a type or method not supported by Unity Flash.
    2. * Details:   Invokes an unsupported method System.Int32 System.Collections.Generic.List`1<exSpriteAnimClip/EventInfo>::BinarySearch(!0,System.Collections.Generic.IComparer`1<!0>) on type System.Collections.Generic.List`1<exSpriteAnimClip/EventInfo>
    3. * Source:   debugging symbols unavailable, IL offset 0x000d at line : 0
    4.  
    and
    Code (csharp):
    1.  
    2.  Usage of a type or method not supported by Unity Flash.
    3. * Details:   Invokes an unsupported method System.Int32 System.Collections.Generic.List`1<System.Single>::BinarySearch(!0) on type System.Collections.Generic.List`1<System.Single>
    4. * Source:   debugging symbols unavailable, IL offset 0x0043 at line : 0
    5.  
    I don't have the source code version, if I did, I'd do something like:
    Code (csharp):
    1.  
    2. #if !UNITY_FLASH
    3. // ex2d usual method for this
    4. #else
    5. // flash hates generics workaround
    6. #endif
    7.  
    Also, I'm not willing to buy the source code version only to fix this compatibility issue :p
    Any ideas?
    Also, is the Unity4.0 friendly version ready yet?
     
  18. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    ex2D doesn't provide this feature. Unity3D have two particle system, and they are good for use.
     
  19. johnny_karas

    johnny_karas

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

    I've consider this but I think I will first start a thread in this forum for ex2D 2.0 open beta. Currently I'm still busy in developing Money Witches. An ex2D Game. I wish I can have more time.
     
  20. johnny_karas

    johnny_karas

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

    I think you are facing the memory problem in your iOS device. Basically you should make sure the peak memory of your game is fit the memory of the target device. After that, if you are crash at loading. Try to move those atlas in Resources/ folder and load them in demand. This will save you from loading too much things when launching the game, but still can't prevent using too much memory if you load them in the game later without unloading unused resources.
     
  21. johnny_karas

    johnny_karas

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

    The exAtlas or exAtlasInfo class have Elements member data in it, it is a List including information you want. You can using any C# serialize function to export these data, so I guess this is what you want.
     
  22. johnny_karas

    johnny_karas

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

    You can send me an E-Mail request a Flash build. But Flash version is really minimum support and have performance problem.
     
  23. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Hi Wu Jie,
    I get a fatal error when i try to import the last update 1.2.7 on a project. I'm on unity 3.5.6f4.
    type == kMetaAssetType pathName.find("library/metadata")!=0
     
  24. nia1701

    nia1701

    Joined:
    Jun 8, 2012
    Posts:
    74
    Hi Wu Jie,
    Can you please explain how exClipping works and how we can add a gameobject to the list by script?
    For a menu i'm instantiating gameobjects that have exsprite and then a sub gameobject with exspritefont. I'd like to be able to clip both of those but am unsure how to add them to exClipping after instantiating? The docs have no information about exClipping as far as I can tell.

    Thanks!
     
  25. raincole

    raincole

    Joined:
    Sep 14, 2012
    Posts:
    62
    Is there any explanation about how to handle different resolutions? For example, I want to target iPad2, iPhone4 and iPhone5. Should I disable pixel perfect? Do I need prepare two set of sprites?
     
  26. CodeFighter

    CodeFighter

    Joined:
    Dec 15, 2012
    Posts:
    63
    Hello, does SetFrame is change current frame index?
    I set frame index by SetFrame, but GetCurFrameIndex() returns me 0 always.
    exSpriteAnimation spanim;
    void Start(){
    spanim = GetComponent<exSpriteAnimation>();
    }

    void OnCollisionEnter(Collision collision) {

    if(spanim.GetCurrentAnimation().frameTimes.Count > spanim.GetCurFrameIndex()){
    spanim.SetFrame(spanim.GetCurrentAnimation().name, spanim.GetCurFrameIndex() + 1);
    }
    else
    Destroy(gameObject);

    print(GetComponent<exSpriteAnimation>().GetCurFrameIndex());
    }

    Can you help me? Thank you!
     
  27. striche

    striche

    Joined:
    Jan 4, 2011
    Posts:
    61
    Ditto. Trying to update a project to Unity 4, due to the set_left exceptions in our current version (1.2.4) we have to update to the latest version. This requires us updating all of our exSoftClip instances (of which there are many) to exClipping. However as UpdateClipList no longer functions we are stuck until some working documentation of this exists somewhere. We see the Is Dyanmic (I assume you meant Is Dynamic) checkbox, but who knows what that does, as there is, again, no documentation.
     
  28. punchi

    punchi

    Joined:
    Sep 27, 2012
    Posts:
    4
    Hi Wu Jie!

    Actually, I'm working with the demo 1.2.5, I think you have many bug fixes and additions with the actual version!! do you have any release date for 3.5.7? =)

    Thanks!
     
  29. johnny_karas

    johnny_karas

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

    Please send me E-Mail to ask for a Unity3D 3.5 build of 1.2.7. The current version in the Web Store and Asset Store are for Unity 4.0.
     
  30. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi trothmaster and striche,

    I will update the document about exClipping this weekend. I'm very busy these months, and delay for most of the things. Sorry about that.

    Let me explain this in short:

    Just use

    Code (csharp):
    1.  
    2. exClipping.AddPlane ( exPlane _plane );
    3.  
    4. exClipping.UpdatePlane ( exPlane _plane );
    5.  
    6. exClipping.RemovePlane ( exPlane _plane );
    7.  
    To dynamically change the plane in clipping component.
     
    Last edited: Dec 19, 2012
  31. johnny_karas

    johnny_karas

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

    The current version of ex2D didn't have solution in multi resolution. You can only use one resolution for different device. Pixel-Perfect is only recommend to use for 3D game.

    I recommend you use Resources.Load to dynamically switch to different sprite when target devices changed. Or just made different scenes for different devices.
     
  32. johnny_karas

    johnny_karas

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

    The curFrameIndex will be -1 when there is no sprite animation play. That's why you get 0 after running the code.
     
  33. johnny_karas

    johnny_karas

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

    The current version have up to date to 1.2.7. You can send me E-Mail to request one.

    Regards,
    Wu
     
  34. rendom

    rendom

    Joined:
    Mar 6, 2012
    Posts:
    2
    Hi.

    I'm making pixelart game. And i need pixel perfect sprites.
    i'm using png files for my sprites.

    But in unity they have this strange white border around them.


    I use texture type: gui; filter: point; format: truecolor

    And.

    I cant play animation via script
    I use

    var spAnim : exSpriteAnimation;

    spAnim.Play("MyAnimationName");

    Error says
    NullReferenceException: Object reference not set to an instance of an object
    EnemyScript.Start () (at Assets/Scripts/EnemyScripts/EnemyScript.js:41)
     
    Last edited: Dec 21, 2012
  35. Yokil

    Yokil

    Joined:
    Sep 9, 2012
    Posts:
    26
    Any news about TileMap?
     
  36. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    i wu jie
    i m not sure what u mean by serialize fonction, i m still a beginner, could u proide me a simple way to achieve that?

    cheers
     
  37. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Hi Wu Jie,
    for a old-school shootemup project, i try to find the best way to fill/switch to (animated) sprite with white color on bullet impact.
    Is there a convenient way to do this in ex2D system ?

    Thanks !
     
  38. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hello Wu Jie,

    Due to structure of code, is it possible to play anim by clip reference instead of clip name? or do I have to generate names at runtime in an array of strings to do this?

    This is because we have 100+ different clips and I have made a small unity component to add clips into with index numbers to simplify which will be copied to the .animations List<> on Start.

    But I cannot find in the API, a method to play by clip reference. If this is not possible, I will generate an array of strings. But please confirm first :)
     
  39. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    Cheers Wu Jie.
    I'm using the latest version of ex2D for Unity 3.5. I understand if I turn on the Animation Helper with a ex2D sprite it will allow me to use iTween to animate the sprite colors? Is that correct?
    I've tried it on a couple instances, and while iTween will no longer generate errors the color doesn't animate for me.
     
  40. johnny_karas

    johnny_karas

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

    To make your pixel-perfect sprite works, you should build the atlas by enable the "Use Contour Bleed" and "Use Padding Bleed". These two option will make sure your sprite will not have color bleed when Unity render them.

    To make your sprite animation playing. Just make sure you have "MyAnimationName" clip added in your sprite animation.
     
  41. johnny_karas

    johnny_karas

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

    It is shame for me to say sorry, but I currently really don't have time making this happen.
     
  42. johnny_karas

    johnny_karas

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

    For example:

    Code (csharp):
    1.  
    2.         System.IO.TextWriter textWriter = new System.IO.StreamWriter(System.IO.Path.Combine(Application.dataPath, "MyAtlas.xml"));
    3.         System.Xml.Serialization.XmlSerializer xml = new System.Xml.Serialization.XmlSerializer(typeof(exAtlas));
    4.         xml.Serialize(textWriter, your_atlas_instance);
    5.         textWriter.Close();
    6.  
     
  43. johnny_karas

    johnny_karas

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

    There are two ways to achieve this:

    1: Use Additive shader instead of alpha blend. So you need to rewrite a shader and make sure the atlas texture and material you used in the sprites share the same effect.

    2: Create two sprite, the white sprite overlap the original one. (This is what we done in Money Witches. Through the way, you can save the draw calls because you only use one type of material in the game). The disadvantage is you have to use PhotoShop or something export the image and the white color shape of it and if you have sprite animation, you have to make sure you sync them when playing this effect.
     
  44. johnny_karas

    johnny_karas

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

    The exSpriteAnimation only store the exSpriteAnimState. The animState is generate at the initial time by loading the clip in it and copy the value from clips. So it needs a way to index animation sate (the name of the clip).

    The exSpriteAnimation already provide a efficient function "void Play ( exSpriteAnimState _animState, float _time )" for playing animation without searching by string. So if you have 100+ anim clips. After you add them to the exSpriteAnimation component, you can store the exSpriteAnimState in somewhere, and play them directly. This is the way to make your code faster.
     
  45. johnny_karas

    johnny_karas

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

    Yes, you have to turn on AnimHelper, and you also need to make sure you are operating the exSprite.color in the iTween not the material's color. Because the exSprite's color will directly change the color of vertices.
     
  46. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thank you, I will do that right now :)
     
  47. bandingyue

    bandingyue

    Joined:
    Nov 25, 2011
    Posts:
    131
    hello wu jie.

    I have a question.

    in exAtlasEditor."Allow Rotate "is always grey.

    how can make the checkbox on?

    rotate is useful in some where.

    One more question.

    when I use SoftClipObject,and put others as child objects in it.then click on "Update" button.

    sprite and animSprite clips well.

    but the font object clips not right.it just shows upper half of it.

    is it a Bug?or something I operate wrong?
     
    Last edited: Dec 28, 2012
  48. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Hi Wu, I am struggling again to sync two sprites.
    Previously, I used events to change the frames of a child sprite according to the frame of the main sprite, it works but this is really time consuming (and probably, CPU consuming).
    Now I am trying to do the same using animations. When I click the "attack" button I start two different animations, one for the player sprite and the other for the child one (the weapon trail I use for collisions). But even if they are correctly timed in the editor, they are played wrong and the trail goes out of sync.
    How can I solve this?
    Thanks
     
  49. simone007

    simone007

    Joined:
    Oct 30, 2008
    Posts:
    221
    Hi Wu,
    I am using your exClip component, but I cannot understand how to add new exSprites to the clipping area dnamically (programmatically)

    Can you help me?

    Thanks
    Simone
     
  50. CrownR

    CrownR

    Joined:
    Jan 2, 2013
    Posts:
    1
    Hi, Wu.

    I got the same problem as simone007,

    I'd like to make a ranking board by ex2D

    It contains spritefont objects and sprite objects,
    those objects would be instantiated by program,

    How sould I add them into Clip Objects list of exClipping?

    Thanks.