Search Unity

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

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

  1. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    is it possible to change the custom resolution from the pixel perfect camera script via code? i did not find anything in the documentation but i need it for my project.
     
  2. MaskedPixel

    MaskedPixel

    Joined:
    Oct 14, 2011
    Posts:
    8
    jwu,

    My pro license was a trial provided for the Ludum Dare game jam. After talking with Unity support, they helped me remove that license and everything works perfect now.
     
  3. johnny_karas

    johnny_karas

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

    You can set this in exPixelPerfectCamera component in your camera.
     
  4. RabidKitten

    RabidKitten

    Joined:
    Apr 15, 2011
    Posts:
    38
    Hello jwu,

    I noticed user fgielow posted the exact same issue I have on this thread. Yet I did not see an resolution to his problem. So i will simply ask again.

    When I used DontDestroyOnLoad my object will freeze animations when loading a new scene. When I click on the object in the editor it starts playing animations again. Is there currently a work around or fix for this issue? What was the end result of fgielow's issue?

    Thanks,

    Tyler
     
  5. RabidKitten

    RabidKitten

    Joined:
    Apr 15, 2011
    Posts:
    38
    Woops double post...
     
    Last edited: Apr 28, 2012
  6. Harter

    Harter

    Joined:
    Feb 28, 2012
    Posts:
    119
    Hello jwu,

    I'm sorry for my silly question, but how can I catch an "OnMouseDown" event with exSprite? And what about touchscreen? I want to make button for mobile devices.

    Thanks.
     
    Last edited: Apr 28, 2012
  7. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    Hi jwu!

    I'm using a script to achieve parallax scrolling using UV-Scroll which works pretty fine.
    I use something like this:
    Code (csharp):
    1.  
    2. void UVScroll(Renderer rend, float dX, float dY){
    3.        
    4.         Vector2 uvOffset = rend.materials[0].GetTextureOffset("_MainTex");
    5.                
    6.         uvOffset.x += dX*Time.fixedDeltaTime;
    7.         uvOffset.y += dY*Time.fixedDeltaTime;
    8.        
    9.         if( rend.enabled )
    10.                 {
    11.                   rend.materials[ 0 ].SetTextureOffset( "_MainTex", uvOffset );
    12.                 }
    13.     }
    14.  
    The only downside is that although it works, it breaks dynamic batching so I end up with many draw calls instead of just 1.
    Is there a workaround to UV-Scroll without messing up batching?

    Thanks in advance,
    delstrega
     
    Last edited: Apr 28, 2012
  8. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332

    i know that i can set it there. but exPixelPerfectCamera only has 2 public functions => CalculateScaleAndRatio and CalculatePixelPerfectScale.

    i was hoping to set height and width via code like i can do in the editor. if it is possible, can you give me an example code how to do it?
     
  9. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Hi jwu, I try to repost this, I am still struggling with it!!!
    This should be a fairly basic question, I believe. Any game usually include complex objects, made up of several sprites. How are they synced???
    I am currently trying using events, but it's way too expensive/looong (I have an event per character frame, on each event I change position and orientation of the weapon) and I am concerned of the overall performance.

     
  10. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi,
    I wondered how to change texture of exSprite by script, and how to get the size of exSprite's current texture.
    Could you tell me please.
     
  11. pleaseplease

    pleaseplease

    Joined:
    Apr 30, 2012
    Posts:
    1
    Code (csharp):
    1.  
    2. exAtlas atlas = (exAtlas)Resources.Load("asset filename");
    3. sprite.SetSprite( atlas, atlas.GetIndexByName("image file name") );
    4.  
    this work well.

    But I wanna know another way to load Atlas files in runtime.
    Because Resources.load only can load build assets.

    I wanna make game that always check update and download texture from web and use it as texture.
     
    Last edited: Apr 30, 2012
  12. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33
    Seriously Guys Im Huge fan of the ex2d and this forum is one of the forum i continuesly read. ex-2d need good tutorial web site. :)
     
  13. myprabath01

    myprabath01

    Joined:
    Sep 15, 2011
    Posts:
    33

    what about making fix animation using Unity animation edior ? as when u attacking change the sward object's roration / position using animation. Im not pretty sure about this. but worth to try. i personally like the event way.
     
  14. rudenko.sergey

    rudenko.sergey

    Joined:
    Apr 3, 2012
    Posts:
    4
    Ok. Thanks for answer. I got it work... but I have decided to just create bundle object and use it for downloading assets all together with included atlas in it.

    I have other question. Can you please point how can I get size of sprite in world coordinates? I'm just trying to put some different sprites near each other, so i should know how much I should displace coordinates. Thanks.
     
  15. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    the ex2d website actually is pretty great tutorial/documentation wise. there are just a few things missing/not clear to me sometimes.
     
  16. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    i cannot change anything with animations. i need to change the camera pixel perfect width and height or my textures do not look the way they should on some devices.
     
  17. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    I'm having an odd problem with the Layer Manager. My situation is this: I have a prefab object which consists of a few objects, including a background with some text on top of it. When the Scene is loaded, 25 of these objects are populated into a pool, then reused as needed. The objects then fall down the screen from top to bottom.

    The part that is not working is that the text constantly appears and disappears, almost as if it is Z-Fighting the background image.

    To solve this, I have been trying to use the Layer Manager, however regardless of what I do, the issue persists. I have a Camera object with the exSpriteMng component added. On the Background and the Text object, both have the exLayer component applied. (I should add that the background is an exSprite and the text is an exSpriteFont).

    When I click 'Edit' in the exLayer component that is attached to the Background object, the hierarchy reads like this:

    Text Background
    |- Text Object

    When I click 'Edit' in the exLayer component that is attached to the Text Object, the hierarchy reads like this:

    Text Object

    This seems to be correct, because the system won't allow me to add Text Background to the Text Object's hierarchy.

    Now, when the scene is created and the objects are populated, I do the following in an initialization method for each of my objects to ensure they are added properly to the exLayerMng component....

    exLayerMng layerManCom = GameObject.Find("Camera2D").GetComponent<exLayerMng>();
    exLayer myLayerCom = eventBackground.GetComponent<exLayer>();

    layerManCom.InsertAt(0,myLayerCom);

    myLayerCom.depth = 1;
    eventText.GetComponent<exLayer>().depth = 0;

    layerManCom.isDirty = true;
    layerManCom.UpdateLayers();

    And this indeed does work. What I end up with, when I go to the Camera object and click Edit on exSpriteMng while the game is running, is a hierarchy that looks like this:

    Camera2D
    |- Text Background
    |-- Text Object
    |- Text Background
    |-- Text Object
    |- Text Background
    |- Text Object
    ... and so forth, for all 25 objects.

    However, even with that, the text continues to pop on and off as if it is Z-Fighting with the background. Based on the above, did I set this up wrong, or is there another tactic that I should be using to prevent the z-fighting?

    Thank you in advance!
     
  18. johnny_karas

    johnny_karas

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

    We've solve the problem in the daily build in v1.2.5 beta. If you can't wait for the release (probably in the middle of May), you can ask me to send a fixed version for urgent use.

    You also can subscribe the newsletter so that you won't miss any daily build.
     
  19. johnny_karas

    johnny_karas

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

    Just follow the Unity3D documentation, OnMouseDown only affect when you have Collision Box in the gameObject. so you just attach a collision box on it.
     
  20. johnny_karas

    johnny_karas

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

    I think you can moving the sprite instead ?
     
  21. johnny_karas

    johnny_karas

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

    The width, height and customResolution is public member data in exPixelPerfectCamera. Is this what you want ?
     
  22. johnny_karas

    johnny_karas

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

    I believe to control animation like this, you need a Pro animation tool and export the data to a specific structure and drive it by ex2D. This is a huge task, we are now researching on several solution, such as use Blender/Spriter to create data that can used by ex2D, or we are going to write our own tools. But still it needs lots of work and test. So I'm sorry but current version of ex2D is not able to do this perfectly.
     
  23. johnny_karas

    johnny_karas

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

    Here is the answer:

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

    http://www.ex-dev.com/ex2d/wiki/doku.php?id=ref:sprite_scripting

    Basically you are not allow to change texture in the run time because they already in atlas and no texture resource will build into the game. But if you wish to use single texture, just change the material.mainTexture of it.

    To get size, just get data from exSprite.boundingRect
     
  24. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You already use Resource.Load(); So you just need to put your atlas, atlas texture and material in the Resource folder and load the atals. Everything's done.
     
  25. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You can get the size by exPlane/exSprite.boundingRect. But we going to change this in ex2D v2.0
     
  26. johnny_karas

    johnny_karas

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

    You don't need to do the red part I marked. Other things looks correct. Just try my advice first. And send me example through EMail if it still have problem. We recently fix a layerManager problem so I want to test if this affect.

    Can you post the version of ex2D you are using ? Thanks in advance.
     
  27. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi jwu,
    Thank you and apologized for those beginner questions,but maybe because of some search engine spider settings of your web,I can't currently found any answer like these link's in google.
    I think this problem will take you much more work here.

    Try search the title "Use Script Create ex2D Sprite By Texture in Editor" in google, nothing show up.
    I was a web programmer before,I think this is abnormal.

    Regard.
     
    Last edited: May 2, 2012
  28. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    jwu,

    I'm afraid making that change you suggested did not make any difference in the z-fighting.

    The ex2D version we have installed is v1.2.5 Beta / 120423, sent in the 'Daily Fix Build' emails.
     
  29. iossif

    iossif

    Joined:
    Mar 4, 2011
    Posts:
    332
    aaaah! somehow there must have been a typo because it did not work the last times i tried. i built the script from scratch and now it can access those public variable. thanks :)
     
  30. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi,
    Problem with 'Object.DontDestroyOnLoad()', if I make an exSpriteAnimation cross scene, it will stop play after 'Application.LoadLevel()' executed even it's 'IsPlaying()' was 'True', except I click and expand 'exSprite' component in Unity editor when running, the animation can play again.
    Has there any way to avoid this ?
    I saw it was already resolved in v1.2.4? but my version is ex2d_indie_v1.2.4_120227
     
    Last edited: May 2, 2012
  31. harlock1975

    harlock1975

    Joined:
    Feb 27, 2012
    Posts:
    46
    Any suggestion on how to get a similar result without complex sprites?
    I mean, I can use a single sprite with character and weapon, but how can I detect when only the weapon is colliding with an object/enemy?
    Thanks again!
     
  32. RabidKitten

    RabidKitten

    Joined:
    Apr 15, 2011
    Posts:
    38
    I would like to make a feature request.

    Can there be a bit more robust color/brightness/contrast adjustments on the sprite base. This would be very helpful. I would like to have enemies flash brighter when hit, or things turn a certain pure color. The current color mode only multiplys a color on top of the sprite. There are tons of different simple post effects (Hue, Saturation, Color Dodge, Color Burn, Overlay, Screen, Multiply....) that could be applied to create a large amount of cool effects that would be simple to implement.

    If you can't implement this, is there a way to do this at the shader level?

    Tyler
     
  33. johnny_karas

    johnny_karas

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

    Please send me a package including this issue. Thanks in advance.
     
  34. johnny_karas

    johnny_karas

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

    Have you try v1.2.5. I think I do another fix for this problem. Anyway, would you mind to send me package including this error ? I can test in my PC first. I believe I've do lots of test to solve this but still can miss something. Thanks in advance.
     
  35. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Just use the Layer system in Unity3D. Please read the documentation about it. Basically you got two layer one for weapon the other for enemy. And in Physics settings set them collide each other.
     
  36. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    Hi RabidKitten.

    Your request can be achieved in two different ways. One is use another sprite as the Overlay and put the color on it for adding color. The other way is write a additive shader and switch the material in the run time. I think unity already provide additive shader, you just need to script to change the material.
     
  37. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    jwu - Where do you prefer I send the package to? There is also a second issue in there as well that I needed to discuss with you, so I can include that in this package as well.
     
  38. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Hi jwu,

    Well I can't upload file here so I transferred my test project to my FTP in U.S. Hope it's helpful.

    link: http://cieo.cn.foxglove.arvixe.com/u3dtest.zip

    And could you give me a basic knowledge of Where to download and update my purchased version?
     
  39. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    Yes, I could prolly just move sprites but with UV-scrolling I can achieve "infinite" scrolling by using texture wrap. That's why I asked.
     
  40. NateJC

    NateJC

    Joined:
    Apr 10, 2012
    Posts:
    58
    The latest version in the Unity Asset Store says v1.2.4. But after installing it, I open the ex2d "readme" file and it says:
    ====== ex2D v1.2.0 Readme ======

    Is that version # just a typo? Or how do I find out what version I really have installed?
     
  41. NateJC

    NateJC

    Joined:
    Apr 10, 2012
    Posts:
    58
    My Unity project pane is getting a little unwieldy and in dire need of organization. This would be greatly helped if I moved all 3rd party plugins and scripts into a folder called "ThirdParty". This worked great for mostly everything, but seems to have problems with ex2D. Is there a way to make the folder structure for ex2D be less rigid? Maybe use relative paths? And I would love it if "_ex2D_AtlasDB" and "_ex2D_SpriteAnimationDB" could be in the ex2D folder as well.

    Thanks.
     
  42. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Guys, have any chance to get something like that:

    I have one Image 320x500.

    And a option to trim that?

    Like i want to clipmask of this object is: 300x300 so the only area visible is that, but i can change that dynamically!

    I already can do that, by code, like this:
    Code (csharp):
    1.  
    2. sprite.customSize = true;
    3.  
    4. sprite.height = 70;
    5.  
    6.  
    7.  
    8. ClipInfo newClip = new ClipInfo();
    9.  
    10. newClip.clipped = true;
    11.  
    12. newClip.top = 0.3f;
    13.  
    14. sprite.clipInfo = newClip;
    15.  
    But maybe this deserve some interface love ;P
     
  43. johnny_karas

    johnny_karas

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

    I understand but you can not scrolling uv cause the sprite is in an atlas, when you change uv it will draw other texture in the scene instead. So in this way you have to use one single texture for uv operation and that makes no advantage in using ex2D. And you can animate the material to achieve this.
     
  44. johnny_karas

    johnny_karas

    Joined:
    Sep 20, 2010
    Posts:
    704
    You can find the version in Window/ex2D/Misc/About

    Also you can specific this in Window/ex2D/Misc/Preference
     
  45. johnny_karas

    johnny_karas

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

    How about put this texture under the softclip instead ?
     
  46. johnny_karas

    johnny_karas

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

    I check your project, and you just need to add this in your LoadS2.cs script :

    Code (csharp):
    1.  
    2.     void OnLevelWasLoaded () {
    3.         GetComponent<exSprite>().renderCamera = Camera.main;
    4.     }
    5.  
    6.  
     
  47. Fove

    Fove

    Joined:
    Feb 15, 2012
    Posts:
    15
    Cool! I'll try.
     
  48. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Softclip seems really heavy for me, I'm wrong?!
     
  49. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    Hi,

    I'm having some issues with black lines on the border of textures. Texture is displayed correctly when it's NOT in the atlas, but if I put it inside the atlas a black border is displayed. Tried different import settings for the texture increased padding in the atlas, with no success.

    How can this be solved? Is there any "correct" settings for imported textures atlas texture? (filtering, etc)

    Thanks!
     
  50. johnny_karas

    johnny_karas

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

    No it is not that heavy.