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. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    Any word on an update that fixes the prefab instantiation with pixel perfect issue? Is there maybe a short-term work-around that you could suggest?
     
  2. johnny_karas

    johnny_karas

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

    Just the GUI released next month. 2.0 still under developing. The upgrade is free.

    Regards,
    Wu
     
  3. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Not yet fix it. I should put the initialize code of pixel perfect in Start, but still not test it. A work around method is don't add the pixel perfect to the prefab. When instantiate, set the renderCamera first. Then set the sprite to pixel-perfect (add the pixel perfect component). I think I can fix this in this weekend. Hope it won't be too late.
     
  4. mr-zafod

    mr-zafod

    Joined:
    Mar 22, 2012
    Posts:
    13
    Hi jwu,

    Got an error using Collision Type = Mesh (unity 3.5, ex2D 1.2.4)

    Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
    UnityEngine.MeshCollider:set_sharedMesh(Mesh)
    ex2DExtension:UpdateColliderSize(exPlane, Single)
    exCollisionHelper:UpdateSize()
    exCollisionHelper:UpdateCollider()
    exSpriteBaseEditor:OnInspectorGUI()
     
  5. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,651
  6. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Probably I am doing something wrong but...
    Basically, I want to resume an animation if it is paused, rather than playing from the start again.
    Here's the code
    Code (csharp):
    1. void PlayAnimation (string key, bool resume)
    2.     {
    3.         Debug.Log(key);
    4.         if (sprite.spanim.IsPaused(key)  resume)
    5.         {
    6.             //Resume the current animation (for step-by-step animations like climbing)
    7.             sprite.spanim.Resume();
    8.         }
    9.         else
    10.             if (!sprite.spanim.IsPlaying(key))
    11.         {
    12.             //Start playing
    13.             sprite.spanim.Play(key);
    14.         }
    15.     }
    But it throws an exception of null reference on the IsPaused line.
    Isn't IsPaused supposed to work like IsPlaying? To fix this, I had to check if the current animation wasn't null before calling IsPaused.
    A minor bug? Or did I miss something?
     
  7. kilt

    kilt

    Joined:
    Oct 12, 2011
    Posts:
    136
    pardon me if this question is already asked, but is ex 2D and the unity rigidbody compatible?
     
  8. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Another question.
    Is there an easy way to link two sprites together and animate them as one?
    My main character can use three different weapons, so I'd like to have the character to be a sprite and the weapon another one. When the player clicks the attack button I'd like to play the attack animation for the character (an ex2d animation) AND sync it with the current weapon swinging (the weapon being a single sprite rotated accordingly).
    Is there any way to do this?
    Thanks!
     
  9. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    EX2D just uses a quad with a texture on it. It manages the animation etc. It can be used in ways that any other game object can.
     
  10. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    I don't know what JWU's recommendation would be. But, you would make the arm a separate object. You'd have the components that make up the arm children within that object. This includes a gameobject whose position represents the attachment point for the weapon. As the arm swings the children swing along with it since the arm is the parent transform. You'd just spawn the sword at the transform position of the empty gameobject transform that you created for the the attachment point. In this way, the weapon swings with its parent. The parent could be the fist, or the arm or whatever is appropriate for your animation.

    Of course that makes a lot of assumptions about how you're animating.
     
    Last edited: Apr 22, 2012
  11. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    I know that using "Texture Offset", frames are automatically aligned even when they are trimmed down in the atlas editor.
    But since this requires prior exact alignment in a graphics application it would be great if a feature could be added to the sprite animation editor that would allow a custom offset per frame.

    I already bought ex2D but the lack of a feature like this a huge let down since I am spending more time in my graphics application fixing pixel offsets per hand than actually working on my game. :/

    It would be great if a "per frame offset" could be added.

    Aside from that ex2D is really great and I want to thank you for this great tool :)
     
  12. kurai

    kurai

    Joined:
    Jan 9, 2012
    Posts:
    118
    Probably it's me, I'm a complete newbie.
    I'm trying to make my sprite face the direction I'm moving. The sprite rotates clockwise or counterclockwise.
    It seems I cannot call hflip(), and plus, I cannot figure out how to decide when to flip and when not.
    Here is my code:

    Code (csharp):
    1. #pragma strict
    2. var speed=40;
    3. var player: String = "Player1";
    4.  
    5.  
    6. function Start () {
    7.    
    8. }
    9.  
    10. function Update () {
    11.     var movement = Input.GetAxis(player);
    12.  
    13.     transform.RotateAround (Vector3.zero, movement*Vector3.forward, speed * Time.deltaTime);
    14.  
    15. }
     
  13. johnny_karas

    johnny_karas

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

    I've fix the problem. And you can check the change log for recently fixes http://www.ex-dev.com/ex2d/wiki/doku.php?id=misc:change_log. We are making a daily build and will deliver to developers later today. Please waiting for it.
     
  14. johnny_karas

    johnny_karas

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

    It looks like you are using some invalid mesh. Can you send me this example for details ?
     
  15. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Aha, thanks alexchouls!! That is really helpful for user who use ex2D with Playmaker! I'll make a link and some introduce later. I will try this first.
     
  16. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Agree. It also depends on your game design and how much details you wish to control. If it is just simple swing, two game object as parent/child will achieve the task. But if more details in which time play the specific animation or control speed by curve. I think you should think about use 3rd animation tools and load the data and apply to ex2D or just create a tool for you to control it in Unity with ex2D.

    Though we plan to create an Animation tool, it won't be very soon.
     
  17. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Nice catch, I doubt I should change the code to

    Code (csharp):
    1.  
    2.     public bool IsPaused ( string _name = "" ) {
    3.         if ( string.IsNullOrEmpty(_name) )
    4.             return (enabled == false);
    5.         else
    6.             return (enabled == false  curAnimation != null  curAnimation.name == _name); <=== added curAnimation != null
    7.     }
    8.  
    Wait for my fix.
     
  18. johnny_karas

    johnny_karas

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

    First of all I want to thank you for your advise and kind words. I will add this suggest in the backlog list and discuss with our artist and designer. We will evaluate if this is a must have feature, and give you feedback in how we think of the problem and how is our expert achieve this tasks.

    Regards,
    Wu
     
  19. johnny_karas

    johnny_karas

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

    There have function

    Code (csharp):
    1.  
    2. exSprite.HFlip();
    3. exSprite.VFlip();
    4.  
     
  20. kurai

    kurai

    Joined:
    Jan 9, 2012
    Posts:
    118
    That's what I tried, but it tells me that an instance of type exSprite is required to access hFlip.
    So I tried adding exSprite sp = GetComponent<exSprite>();
    But at this point I get another error (unexpected token). And I'm totally blocked.
    Plus I really cannot figure out how to detect the change of direction to call hFlip at the right moment (but I'll figure out this later).

    Thank you!
     
  21. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    The base class I am using for an Actor class has these protected variables:

    Code (csharp):
    1.     protected var spriteObj : exSprite;                         //Reference to the linked ex2D sprite. 
    2.     protected var spriteAnimation : exSpriteAnimation;          //Reference to the linked ex2D sprite animation.
    which I initialize in the following way:

    Code (csharp):
    1.         spriteObj = GetComponent.<exSprite>();
    2.         spriteAnimation = GetComponent.<exSpriteAnimation>();
    and when I detect the object has to flip I do:

    Code (csharp):
    1.  
    2. spriteObj.HFlip();

    So far it seems to be similar to what you have done, so I would suggest you to double check the code and the components attached to the game object.
     
  22. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    Code (csharp):
    1.  spriteObj = GetComponent<exSprite>();
    -->

    Code (csharp):
    1.  spriteObj = GetComponent.<exSprite>();
     
  23. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    Is there a github project for ex2d pro users?
     
  24. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33
    Im developing Game that Look like Street of Rage.



    So I need to change the Layer Rendering Order according to Y position of Player. So My question is How to change the Layering order in Layer Manager and are there any Good Tutorial or Reference doc about how to use ex2d Layer Manager.
     
  25. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    You might find some help in this posts and other posts before that: http://forum.unity3d.com/threads/10...Unity-RELEASED?p=878025&viewfull=1#post878025
     
  26. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Thanks, ShawnMcCool!
    Right now, I have the whole character animated in a single sprite and I want to have the weapon as a separate one to be able to use its collider to deal damage to enemies. I do not have any skeleton system.
    Even if I separate the arm from the rest of the character, how can I change the attachment gameobject position according to the arm frame currently showing?
    As the arm animation (swinging included) is just a sequence of different frames, each frame having a different position for the weapon, how am I supposed to sync them?
    Thanks again for your advice!
     
    Last edited: Apr 23, 2012
  27. johnny_karas

    johnny_karas

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

    You can send me the project may be I can help you point out the problem.
     
  28. johnny_karas

    johnny_karas

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

    The github repo for private access is expensive with huge number of users. I don't think we currently afford it. If you wish to get a daily version, you can just send me the E-Mail and I will get pack for you.

    Also we are consider establish a git repo in our own sever for Pro user access and grab the code at October this year.
     
  29. johnny_karas

    johnny_karas

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

    1. In short, create a Dynamic Layer as a Block of Depth Buffer between Foreground and Background (normal layer). Set the range of dynamic layer as what you want for example 200.

    2. Now organize your character prefab in layer mng, save the changes.

    3. Instantiate the prafab, and insert your character to layer by:

    Code (csharp):
    1.  streeLayer.InsertAt ( 0, myCharacter.GetComponent<exLayer>() );
    4. Now it is your business to sort the child in the streeLayer. For example since you are a Range Of Stree game. You draw order should depends on Y. So you can sort your child by the low to high of the position.y. And remember only sort the characterLayer, not its child.

    5. I doubt you can't access the exLayer.children_ since it is protected. So you have to inherit from exLayer, and create your special layer for sorting. Remember call
    Code (csharp):
    1. layerMng.AddDirtyLayer(this);
    for each time you sort the layer, that will let layermng do the real update.

    If you are not familiar with writing a special layer, read the original layer code here:

    https://github.com/jwu/ex2D_Runtime/blob/master/ex2D/Core/Component/Helper/exLayer.cs
     
  30. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi!

    Does ex2d already support dynamic lighting (there were some discussion earlier in this thread)? I can't find any option for it.

    If not, would it be possible to have an option to enable normals (or similar) to allow utilization of dynamic lighting (even it is causing some performance hit when used).

    I'm currently making a 2.5D/3D game for IOS (ex2d currently used for some objects) and I love to utilize more ex2d. The game itself utilizes directional light and potentially other (point/spot) light sources in specific levels, so I need to use shaders like diffuse/transparent diffuse/Vertex-Lit etc.

    About the texture atlasing, I assume that the utilization of different shaders (for different effects) requires own materials for each shader (and thus own atlases).

    Br,

    - Moopi
     
  31. MaskedPixel

    MaskedPixel

    Joined:
    Oct 14, 2011
    Posts:
    8
    I cannot create an atlas. The error I am getting is:


    UnityException: Creating asset at path Assets/player/atlas\test - EditorInfo.asset failed.
    exAtlasInfo.Create (System.String _path, System.String _name)
    exAtlasInfoUtility.CreateAtlasInfo (System.String _path, System.String _name, Int32 _width, Int32 _height)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/GUI/DockArea.cs:223)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/GUI/DockArea.cs:216)
    UnityEditor.HostView.OnGUI () (at C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/GUI/DockArea.cs:121)

    I am on Windows 7 64bit. How do I get this working?
     
  32. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If I was giving out awards for the best developer feedback and communication it would go to jwu. It is very rare and to be congratulated. It has convinced me to purchase.
     
  33. kellygravelyn

    kellygravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    Any chance of improvements to the texture atlas packing algorithm or, even better, support for externally created sheets made with the Texture Packer tool? I'm finding the packing algorithm is not very optimized when you have lots of different sized sprites whereas Texture Packer has great results. It'd be great to be able to use that tool to make sprite sheets and simply import them into ex2D.
     
  34. johnny_karas

    johnny_karas

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

    I think in the latest version, I'm already enable the normal for all sprites. So you just need to change your shader to support it.
     
  35. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi MaskedPixel

    Can you show me the version of ex2D and the version of Unity3D you are using? It is less information in this error.
     
  36. johnny_karas

    johnny_karas

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

    I will consider this later. Thanks for your advice. Currently we don't have much resource in supporting external texture packer tools. But it would be nice if I can import their result to atlas editor.
     
  37. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    Hi again Wu!

    I encountered a strange bug(?) when using "Custom Size" together with "Use Texture Offset".
    Got an animation with 3 frames (each 192x180 pixels) running perfectly in the animation editor. The frames get trimmed in the atlas editor but since I got "Use Texture Offset" they get aligned correctly.

    The problem is that I use "Custom Size" with width and heigh at "1" for all my sprites so that unity's physics behaves normally and sprites don't get huge. This way their size at scale (1,1,1) is that of a regular unity primitive. I don't like to adjust the scale of my sprites to strange values like 0.00000123 since that seems to mess up physics.

    Now when I try that animation ingame the sprite jumps left and right. If I disable "Use Texture Offset" the jumping is gone, but now, since they were trimmed down in the atlas editor the frames alignment is wrong.

    Is there anything I can do to fix this?
     
  38. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi!

    It seems that the lighting does not work correctly for ex2D sprites with H-flip or V-flip on (sprites seems to be ok when both flips are off or both are on). I'm using standard diffuse/transparent diffuse shaders.

    In my game, I'm using four ex2D sprites to create the background in the way that they are rotated/flipped (example: a texture have one quarter of circle, with flipping, you can create whole circle with four sprite objects and one texture by using flip/rotation -> your level background requires only 1/4 of the memory when compared to one big texture)

    Br,

    - Moopi
     
  39. GKhanDev

    GKhanDev

    Joined:
    Apr 25, 2012
    Posts:
    1
    Hi jwu,

    I'm getting some errors with the evaluation version of ex2D, I'm currently using Unity 3.5.1f2 Free Version and Windows 7 64.

    I saw people getting this error too and i couldn't find a solution.

    Here's the error:

    [C:/BuildAgent/work/b0bcff80449a48aa/Editor/Src/AssetPipeline/AssetInterface.cpp line 1787]
    (Filename: C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/GUI/DockArea.cs Line: 228)

    UnityException: Creating asset at path Assets/.ex2D_SpriteAnimationDB.asset failed.
    at (wrapper managed-to-native) UnityEditor.AssetDatabase:CreateAsset (UnityEngine.Object,string)

    at exSpriteAnimationDB.CreateDB () [0x00000] in <filename unknown>:0

    at exSpriteAnimationDB.Init () [0x00000] in <filename unknown>:0

    at exSpriteAnimationDB.GetSpriteAnimClipGUIDs (System.String _textureGUID) [0x00000] in <filename unknown>:0

    at exAtlasInfo.AddSpriteAnimClipForRebuilding (.Element _el) [0x00000] in <filename unknown>:0

    at exAtlasInfo.LayoutElements () [0x00000] in <filename unknown>:0

    at exAtlasEditor.OnGUI () [0x00000] in <filename unknown>:0

    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception)

    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

    (Filename: Line: -1)

    Refresh, detecting if any assets need to be imported or removed ... 0.011515 seconds (Nothing changed)
    Refresh, detecting if any assets need to be imported or removed ... 0.018589 seconds (Nothing changed)
    'Assets/.ex2D_AtlasDB.asset' is not a valid asset file name.
    UnityEditor.AssetDatabase:CreateAsset(Object, String)
    exAtlasDB:CreateDB()
    exAtlasDB:Init()

    [C:/BuildAgent/work/b0bcff80449a48aa/Editor/Src/AssetPipeline/AssetInterface.cpp line 1787]
    (Filename: C:/BuildAgent/work/b0bcff80449a48aa/Editor/Src/AssetPipeline/AssetInterface.cpp Line: 1787)

    UnityException: Creating asset at path Assets/.ex2D_AtlasDB.asset failed.
    at (wrapper managed-to-native) UnityEditor.AssetDatabase:CreateAsset (UnityEngine.Object,string)

    at exAtlasDB.CreateDB () [0x00000] in <filename unknown>:0

    at exAtlasDB.Init () [0x00000] in <filename unknown>:0

    (Filename: Line: -1)

    I'm testing out your tool, it's seems really really good but with this error i can't use it properly, the sprites are loosing the connection with the atlas all the time.

    Those 2 files (.ex2D_AtlasDB.asset and .ex2D_SpriteAnimationDB.asset) seems to be the problem.

    Thanks.
     
  40. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Btw, what is the default scale of ex2D? Is it possible to set it somewhere? I'm using a plane of 30x20 as a basic unit for screen background (1=16 or 32 pixels in iPhone), mening that with ex2d, the scale for a sprite must be set to be 0.005 to be close to1 in the default Unity scale.
     
  41. johnny_karas

    johnny_karas

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

    You are right. I think I should calculate texture offset depends on calculated size instead of original size. Let me check the code deeply and test in scale, custom size mode for few days.

    I'll update the issue: https://github.com/jwu/ex2D_Runtime/issues/32. Wait for it.
     
  42. johnny_karas

    johnny_karas

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

    Another nice catch of the bug. I think I can set the normal always face to camera no matter which flip applied. I'll fix the problem asap.

    Here is the issue for trace: https://github.com/jwu/ex2D_Runtime/issues/33
     
  43. johnny_karas

    johnny_karas

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

    The evaluation version is too old to run in Unity 3.5. We will update the evaluate version in May, currently, just send me an E-Mail and I'll prepare an evaluation version for 3.5.
     
  44. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You can set the scale in Sprite Inspector. There have an option Scale that have x,y for you to adjust.
     
  45. MaskedPixel

    MaskedPixel

    Joined:
    Oct 14, 2011
    Posts:
    8

    My Unity info:

    Version 3.5.0f1 (3ad644b41f36)
    Developer Preview - Fri, 20 Jan 2012 21:40:04 GMT
    License Type: Unity Pro, Asset Server, iPhone Pro, Android

    My ex2d info:

    v1.2.4 (120227)
    Support Platform: iPhone

    My guess is the problem is the Support Platform. I don't know how to change that though...

    Thanks for taking a look at this.
     
  46. MaskedPixel

    MaskedPixel

    Joined:
    Oct 14, 2011
    Posts:
    8
    Double posted... Sorry
     
    Last edited: Apr 26, 2012
  47. damienthorn

    damienthorn

    Joined:
    Oct 1, 2009
    Posts:
    28
    I'm really interested in trying ex2D with the evaluation version in Unity 3.5. Please update the evaluation version as soon as possible.
     
  48. rudenko.sergey

    rudenko.sergey

    Joined:
    Apr 3, 2012
    Posts:
    4
    Hello.

    Can someone please specify if there is option to set sprite image without atlas?
    I'm just want to download image from some external url as Texture2d (by using WWW class) and put that as image in exSprite.
    Is that possible?

    Thanks.
     
  49. johnny_karas

    johnny_karas

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

    I'll try to find a Window 64bit PC reproduce the problem. Currently it works well in my Mac, Window 7 32bit.
     
  50. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Just set render material.mainTexture to the texture you want. But in this way you are loosing the power of batches.