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

    You can change the texture offset by exSprite.offset property.
     
  2. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    251
    I'm having some trouble updating from "ex2D v1.2.6 (120527)" to "ex2D v1.2.6 (120901)"
    [Edit: corrected date to 120901]

    I'm getting one warning and one error:

    Assets/Plugins/ex2D/Core/Component/AnimationHelper/exSoftClipAnimHelper.cs(49,24): warning CS0109: The member `exSoftClipAnimHelper.Update()' does not hide an inherited member. The new keyword is not required

    Assets/Plugins/ex2D/Core/Component/AnimationHelper/exSoftClipAnimHelper.cs(50,14): error CS0117: `exSpriteBaseAnimHelper' does not contain a definition for `Update'


    I should also mention that I have moved ex2D into the 'Assets/Plugins' and 'Assets/Plugins/Editor' folders, since that is necessary to interface with the library from other languages. Building DLL's is something I don't want to do unless strictly necessary.
     
    Last edited: Oct 22, 2012
  3. johnny_karas

    johnny_karas

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

    The exSoftClipAnimHelper is been deleted in v1.2.6. I think the problem is you are using the ex2D Pro version, but happen to missing delete these files.

    Regards,
    Wu
     
  4. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    251
  5. MrBoolean

    MrBoolean

    Joined:
    Jan 7, 2012
    Posts:
    197
    hey how would I make a sprite object with the EX2D Sprite component flip different directions when I press right or left? Here is my code when the jumpman sprite moves:

    Code (csharp):
    1.  
    2.  
    3. if (Input.GetKey ("d") || Input.GetKey ("right"))
    4. {
    5.  this.transform.Translate(2,0,0);
    6.  
    7. }
    8.  
    9. if (Input.GetKey ("a") || Input.GetKey ("left"))
    10. {
    11.  this.transform.Translate(-2,0,0);
    12. }
    13.  
    14.  
    this is a simple movement code test to make jumpman (from donkey kong, to go left/right).
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi guys,

    I need to attach weapons or things to sprites in ex2D - such as hats and swords. To do this I need to retrieve the current frame that is playing, and also set the current frame and also get the number of frames.

    I don't need "time" but I can't see where I work with "frames" in the API - any suggestions?
     
  7. johnny_karas

    johnny_karas

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

    There is HFlip and VFlip function in exSprite. You can call these functions for flipping.
     
  8. johnny_karas

    johnny_karas

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

    The exSpriteAnimation.GetCurFrameInfo() will help you get the information. If you just want the frame index, call exSpriteAnimation.GetCurFrameIndex()
     
  9. MrBoolean

    MrBoolean

    Joined:
    Jan 7, 2012
    Posts:
    197
    Hey Wu thanks for replying I can't seem to figure out the Script Reference definition for the HFilp... I wrote the code like this:

    Code (csharp):
    1.  
    2. function Update () {
    3.  
    4. if (Input.GetKey ("right"))
    5. {
    6.  this.transform.Translate(2,0,0);
    7.  
    8. }
    9.  
    10. if (Input.GetKey ("left"))
    11. {
    12.  this.transform.Translate(-2,0,0);
    13.  void exSprite.HFlip( );
    14. }
    15.  
    16. }
    17.  
    18.  
    and I got this error:

    Assets/Scripting_Basics_1.js(18,6): UCE0001: ';' expected. Insert a semicolon at the end.
    I'm not sure if I called that right, many thanks for your help!
     
  10. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    596
    @MrBoolean:

    I take it that you are new to this.

    Why are you trying to call that method with a "void"? that's for a new method that you are defining. Besides even if that code works it will make that your character flips every time that you press the key.

    You should reference the exsprite component of your gameobject. First, in Start() put the component in a variable for easy reference:

    Code (csharp):
    1. sprite = GetComponent<exSprite>();
    And then make sure that only the first time that the player press left (or when he press right after being going left), the character flips. For that, honor your nickname and use a boolean:

    Code (csharp):
    1.  
    2. if(isFlipped){
    3.     sprite.HFlip();
    4.     isFlipped = false;
    5. }
    6.  
    Regards.
     
  11. MrBoolean

    MrBoolean

    Joined:
    Jan 7, 2012
    Posts:
    197
    okay when I wrote like this:
    Code (csharp):
    1.  
    2.  
    3. #pragma strict
    4.  
    5. function Start ()
    6. {
    7.         var sprite = GetComponent<exSprite>();
    8. }
    9.  
    10. function Update () {
    11.  
    12. if (Input.GetKey ("left"))
    13. {
    14.  this.transform.Translate(-2,0,0);
    15.  }
    16.  if(isFlipped)
    17.  {
    18.     sprite.HFlip();
    19.     isFlipped = false;
    20.  }
    21. }
    22.  
    23.  
    24. if (Input.GetKey ("right"))
    25. {
    26.  this.transform.Translate(2,0,0);
    27.  
    28. }
    29.  
    30.  
    31.  
    I got these errors:
    Assets/Scripting_Basics_1.js(5,55): UCE0001: ';' expected. Insert a semicolon at the end.

    Assets/Scripting_Basics_1.js(5,54): BCE0044: expecting ), found ';'.

    Assets/Scripting_Basics_1.js(5,55): UCE0001: ';' expected. Insert a semicolon at the end.
     
  12. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    596
    My samples of code were C#, you are using JS. You must translate it first (for instance, the GetComponent line is different in JS).

    And the declaration of the variable sprite must be outside of Start so it can be visible to the Update function.
     
  13. MrBoolean

    MrBoolean

    Joined:
    Jan 7, 2012
    Posts:
    197
    okay i got the errors fixed, but when I press left the player doesn't move left, also the sprite doesn't flip. here is my code:

    Code (csharp):
    1.  
    2.  
    3.  
    4.  var sprite = GetComponent(exSprite);
    5.     var isFlipped;
    6.  
    7. if (Input.GetKey ("left"))
    8. {
    9.  this.transform.Translate(-2,0,0);
    10.  }
    11.  if(isFlipped)
    12.  {
    13.     sprite.HFlip();
    14.     isFlipped = false;
    15.  }
    16. }
    17.  
    18.  
    19. if (Input.GetKey ("right"))
    20. {
    21.  this.transform.Translate(2,0,0);
    22.  
    23. }
    24.  
    25.  
    26.  
     
    Last edited: Oct 30, 2012
  14. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks for advice, Wu.

    Do you sell a version with source code as I am interested in extending the animation window so I can place hotspots that rotate as well per frame index, so I can add little positions for hats and swords etc ... or perhaps this is a feature you are interested in for 2.0?
     
  15. mntcarp

    mntcarp

    Joined:
    Dec 12, 2011
    Posts:
    25
    Hi everyone!
    Could anyone explain me what exactly the "pixel perfect" option do, please?
    I mean, I know it makes my 2d textures smaller, but why?
    The problem is that this is a concept that I can't find it in Spanish (which is my main language), and english wikipedia doesn't help much either.

    Thank you!!
     
  16. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I've PM you.
     
  17. johnny_karas

    johnny_karas

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

    The pixel perfect feature in ex2D will resize the spirte texture to fit your resolution that affect by camera. This feature will make sure your texture draw in the screen with the same size as it is in the disk. But ex2D's pixel perfect didn't do half pixel offset, which is a common problem in rendering 2D sprite. You can find more details of this problem here (http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/)
    I'm going to fix this in the next version of ex2D.
     
  18. nia1701

    nia1701

    Joined:
    Jun 8, 2012
    Posts:
    74
    Hi Wu Jie,
    Is it possible for the SpriteBlend shader to respond to light and still be able to change the color property from the inspector? I tried changing Lighting to On in the shader but it just turned the texture to black..
    Thanks!
     
  19. Panajev

    Panajev

    Joined:
    Mar 26, 2012
    Posts:
    42
    It is possible, but the quad/sprite is not processing normals, so you can do that but you need to customize lighting a bit.
     
  20. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    Hi, how do I rotate a sprite using exTextureHelper::RotateDirection?

    [never mind, I see this is just for the editor. is there another way to do this w/o using transform.rotate?]
     
    Last edited: Nov 7, 2012
  21. vpin

    vpin

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

    I have a texture, how do I know to which it belongs atlas at runtime?

    Regards.
     
  22. johnny_karas

    johnny_karas

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

    It is possible to use lighting, and exSprite passing normal to vertex, I think it relate to what kind of lighting shader you are using.
     
  23. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You don't know the texture, because in runtime, the only texture you are using for exSprite is the atlas texture, there is no single texture in the Runtime, actually they will not build in the game.
     
  24. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    Hello, happy ex2d owner here. Is ex2d working at all in Unity4 or am I just doing something wrong? It was working in the earliest Unity4 beta, but not the more recent ones.
     
  25. Xellinus

    Xellinus

    Joined:
    Jan 28, 2012
    Posts:
    44
    Ok I'm going crazy trying to get a mesh collider setup with a sprite. Sometimes it shows up and sometimes it doesn't, but it NEVER lines up with the sprite. It's rotated all sorts of weird and no matter how much I seem to mess with it's rotation in blender it comes out the same annoying thing when I set it as the collider on the sprite. Always the same spot in the middle of the sprite rotated awkwardly.

    Is there an easier way to have a mesh collider with ex2D? I don't want boxy levels.
     
  26. WillBellJr

    WillBellJr

    Joined:
    Apr 10, 2009
    Posts:
    394
    What helped me with creating accurate collision shapes was to buy RageTools which then let me draw my collision shapes which I would then use with my sprites.

    I think I have some posts earlier in this thread and/or the RageTools thread about my doing just that.


    -Will
     
  27. Xellinus

    Xellinus

    Joined:
    Jan 28, 2012
    Posts:
    44
    Ahh but that costs a hefty amount. It also just adds the functionality that tk2d has for the price of tk2D. I've already put my (money) support behind ex2D so I'd like to continue along that route.

    But thank you still.
    -x
     
  28. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I'll check the problem this week.
     
  29. johnny_karas

    johnny_karas

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

    Can you send me a project with this problem, I can help you find out what's wrong in it.
     
  30. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I've test most of the function in ex2D v1.2.7 With Unity 4.0. Only one parameter need to be fix in exGUIBorder to prevent RectOffset setup in loading thread. So I'm happy to say ex2D is naturally support Unity 4.0. User can seamless upgrade ex2D project from Unity3 to 4.

    My own game Money Witches just upgrade and running perfect with ex2D in both Mac and iOS.

    I will test ex2D in PC Windows7 tomorrow.
     
  31. figbash

    figbash

    Joined:
    May 13, 2008
    Posts:
    60
    Can you please fix this now that 4 is out? Using ex2D for my companies project has completely killed our productivity as we were not able to move to Unity 4 early, and 4 requires many code changes for us. I really need this to work soon...

    ArgumentException: set_left can only be called from the main thread.
    Constructors and field initializers will be executed from the loading thread when loading a scene.
    Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
    UnityEngine.RectOffset..ctor (Int32 left, Int32 right, Int32 top, Int32 bottom)
    exGUIBorder..ctor ()
     
  32. nia1701

    nia1701

    Joined:
    Jun 8, 2012
    Posts:
    74
    Great news! How do we get version 1.2.7 though?
     
  33. johnny_karas

    johnny_karas

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

    I just fix this problem as I said above.
     
  34. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    I will send a newsletter first tomorrow morning, and submit to Asset Store later. wait for it.

    But even v1.2.6 can running on Unity 4. Only the set_left error appear, but this will not block you running the game before v1.2.7 comes.
     
  35. nia1701

    nia1701

    Joined:
    Jun 8, 2012
    Posts:
    74
    great thanks for the updates!
     
  36. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
  37. Xellinus

    Xellinus

    Joined:
    Jan 28, 2012
    Posts:
    44
    I went about a simplification of my level design and don't have a project available that illustrates this problem off hand. I could whip one up, but essentially, it's a problem with the mesh import I believe.
     
  38. soulburner

    soulburner

    Joined:
    Mar 25, 2012
    Posts:
    167
    I want to say, my team is stucked with ex2D pipeline... :(

    The whole developing process (2 programmers, 10+ artists, etc.) is now in crysis. And the reason is that Unity is 32 bit and crashes when it tries to use more than 2.9 Gb RAM.

    The problem is there are tons of PNGs that are composed into atlases (for now we have about 4000 sprites and the number is growing).

    The main reason is that when you build a project, it seems to be that unity re-compresses ALL images. No matter that all these tons of PNG are not needed for run (they all only needed for atlas build only). But Unity begins to grab all files, grow its memory usage and when it is around 3 Gb - crashes.

    We're totally stucked and don't know what to do. The project is near to release date, it runs ok in editor, but crashes with out of memory when is tried to built (tries iOS under Mac and standalone under Win).


    The only way I can see for now is to somehow build all atlases in some software aside Unity and somehow force ex2D engine to load these atlases...
     
  39. johnny_karas

    johnny_karas

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

    I can offer you a quick fix by adding GC.Collect after every texture loading function in Editor. Would you mind to contact me through E-Mail. I will help you build and test it.

    Regards,
    Wu
     
  40. johnny_karas

    johnny_karas

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

    This is the best graphic I saw that making by ex2D, Can I add this in my ShowCase page, and would you mind to PM me your E-Mail address, so that I can discuss with you about ShowCase later.
     
  41. soulburner

    soulburner

    Joined:
    Mar 25, 2012
    Posts:
    167
    Thanks a lot. But there's no need. We switched atlas building to TexturePacker, wrote xml->exAtlas converter and deleting all original sprites from a project before build.

    Hope will share with you the result of our 5 months job in about a month :)
     
  42. johnny_karas

    johnny_karas

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

    I'm glad to hear that, and I will do more memory operation testing during my developing of ex2D in Unity 4.0. I think I've found the problem, it is because I have to call GC.Collect even in Editor, this will immediately release all texture memory when you set the texture to null.

    Anyway, if you have any thing urgent for fix, try to contact me through E-Mail.
     
  43. Galiastr

    Galiastr

    Joined:
    Nov 20, 2012
    Posts:
    1
    Hi Wu Jie,

    Can you help me with my problem.
    I have exClipping component on object and dynamically created objects as childs.
    In code I get clipping component and add plane in exClipping:

    mask = gameObject.GetComponent("exClipping") as exClipping;
    foreach(Transform child in item.transform)
    {
    exPlane plane = child.GetComponent<exPlane>();
    mask.AddPlane(plane);
    }

    also I try mask.InsertPlane(0, plane); method.

    Problem that in Editor even on Android type of project work all fine, but on device code is corrupt when I try add plane in exClipping component.
    I debugged step by step and all objects and components are not null, all object present but code dont functionality after AddPlane on android device.
    Version of ex2d - 1.2.6
    And please can you fill you script reference and documentation about component exClipping.
    When I used exSoftClip in past all work fine, because child was init automatically and I should only call UpdateClipList and thats all.
    Please help, because any other method realisation of masks are don't usefull for my situation.

    Thanks!
     
  44. johnny_karas

    johnny_karas

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

    I think the problem can be solved by adding "SpriteBlendClipping.shader" file into your Resources/ folder when compile to android or ios devices. This problem is caused by missing reference to the clipping shader. Because when you add plane dynamically, you don't have reference to the clipping shader and unity will not including it in the build.
     
  45. johnny_karas

    johnny_karas

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

    Please send me your package through E-Mail, I can help you check the problem.
     
  46. ShawnMcCoo1

    ShawnMcCoo1

    Joined:
    Dec 26, 2011
    Posts:
    39
    I also just switched to TexturePacker. Would you be able to share your XML to exAtlas converter? I understand if not, just may save me some time.

    Edit: Actually, I just looked at the script reference and nevermind. It's very basic.
     
    Last edited: Nov 22, 2012
  47. soulburner

    soulburner

    Joined:
    Mar 25, 2012
    Posts:
    167
    Yeah, that's quite simple. It took me about half an hour to write it and another half an hour to automate some things like texture import settings and materials.
     
  48. joedgrant

    joedgrant

    Joined:
    Mar 16, 2010
    Posts:
    23
    Hi, just had a few questions. Is an updated version of the eval version being released? Looking at it for a project (running in 4) but hitting a few snags. No problems getting animations to play on sprites or anything, but the animation editor bogs down a lot on larger sprite sheets.
     
  49. punchi

    punchi

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

    Nice 2D implementation!, I'm starting Unity with a 2D game and Im starting with this software. I'm a little stuck with inheriting a exSpriteAnimation code. Do you have any tutorial with JS/C# and ex2D?? by creating:

    Code (csharp):
    1. public class Bandera : exSpriteAnimation {
    2. ...
    3. void OnCollisionEnter(Collision collision) {       
    4.   if(collision.gameObject){
    5.     Debug.Log("COLISIONANDO!");
    6.     this.PlayDefault();
    7.     Debug.Log("isplaying:" + this.IsPlaying("base"));
    8.     };
    9. }
    10.  
    the console shows the "COLISIONANDO!" and "isplaying: 1", but the animation doesn't play. This is the animation:

    $dont.png

    and it's strange, because when I switch the animations (the flag first, later the aguile) when the object collisions, the animation its changed. its supposed that it should be changing all the time (Ping Pong wrap) but it just change the image... what I'm doing wrong? :roll:

    Thanks Wu! ^_^
     
  50. F

    F

    Joined:
    Sep 28, 2012
    Posts:
    13
    Hi jwu,
    This confuse me for a long time.
    I've tried change animClip.speed in code ,but this will effect at next time program run,even I removed and added it,even I reloaded resource.
    Can I change animation playing speed dynamically?
     
    Last edited: Nov 28, 2012