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

SimpleSprite 2D utility now free and open source

Discussion in 'Assets and Asset Store' started by karl_, Mar 11, 2012.

  1. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    SimpleSprite, a 2D solution for Unity is now free and open source.

    Current Features:
    • Dynamic batching support
    • UI Atlas Builder
    • Runtime Sprite Class
    • Drag and Drop workflow
    • Save and edit atlases
    • Tile Map Editor (available in source code repo, not package)
    • Auto-generated sprite mesh w/ configurable anchor
    • etc

    Download the package here:
    SimpleSprite

    If you feel so inclined, you may contribute to the project over at Google code :
    Subversion Repository

    All contributions are welcome.

    The package only includes the Atlas Builder and run-time Sprite class. The source code on the other hand contains the work in progress TileMap editor as well as a few miscellaneous tools.

    Here are a few (out of date) screens:





     
    Last edited: Jul 24, 2012
  2. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    Looks good. I will download it now.

    Edit: I have just tested this as well as orthello and ragepixel and this wins hands down!
    It is easy to use, and I have not found any bugs yet.
     
    Last edited: Mar 12, 2012
  3. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,568
    I think I'll download this as well.
     
  4. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Good initiative, congratulations!
     
  5. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Thanks guys. I hope you find it useful.

    And of course, if you make changes please submit to the repository!
     
  6. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Very cool , how do i build to get the title mapper ,
    I really want to make this type of old school game, please PM me with instructions on how to build from source
     
  7. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    To use the Tile Mapper you will need to check out the source code. It's still rough around the edges, hence not being included with the main package. If you're unfamiliar with SVN, the easiest way to do this is either via Terminal
    Code (csharp):
    1. svn co http://code.google.com/p/simplesprite/source/checkout
    or with an SVN gui client like SvnX or TortoiseSVN. If there's enough demand I suppose I could submit a separate package with the tile mapper included.
     
  8. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    karl_, is there a way I can make a donation? I want to support this.

    Just when I thought nobody's going to make an opensource 2d plugin for Unity, and then BANG! Two of them in one week!

    Thank you for making it free and opensource :)
     
  9. Anefiox

    Anefiox

    Joined:
    Mar 30, 2012
    Posts:
    1
    Does anyone know how to use the tile editor? I've imported the extra files from SVN and can add the tile script and setup the ground tiles, but I'm not sure how to draw them to the scene. Do I insert a plane and then draw them to that?
     
  10. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    Just tried it and it's simple and easy to use so far. Still, many options are still obscure as to what do they do and how they work , for instances, Make Unique and Pixel Perfect.

    Do you have a plan to add Orthographic Camera support? I find ortho camera to be easy to work with when I work with SpriteManager2. I'll see if I can modify the code to add this feature :)
     
  11. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Thanks for making this available !
     
  12. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Make Unique and Pixel Perfect probably could be named a bit better like you said, but until I can think of better terminology here is what they both do:

    Make Unique - Creates a new mesh specifically for the selected sprite. If you're duplicating and moving around Sprites, by default they will share a mesh. Selecting `Make Unique` makes it so that that sprite will have it's own mesh, meaning that it may have it's own UV coordinates and material data without affecting any of the other Sprites in the scene.

    Pixel Perfect - If selected, SimpleSprite will scale the mesh at run-time to match the dimensions of the image it is currently displaying. (Say you're displaying a 128/32 dimension sprite- the mesh will scale itself to 4/1, either by extending X or decrementing it's Y value, depending on what you've set the scale values to).

    I'm not sure what you mean by orthographic camera support though, I've not used SpriteManager2. However, I usually use the Orthographic camera when working, and have had no issue. Are you referring to a setting in the code to force Orthographic views?

    Quick Edit: I just committed a few small changes, as well as a new package to download. The new package now includes the Tile Editor too.
     
    Last edited: Apr 17, 2012
  13. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    Thanks for the answer! Maybe it's on my part, but when I use Orthographic camera, the sprite was not correctly displayed, I'll try again with Pixel Perfect and see how it goes. As for the name, I think the problem can be solved by documentation so don't worry too much about it :)
     
  14. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    Just saw your edit. Glad to see the Tile Editor in there!

    Also, I was wondering is it possible to create sprite and sprite atlas at runtime with this? I could do it in SpriteManager2, and this will allow me to create a game with user custom content. I suppose the way to do it would be to call plugin's build atlas method but supplying all the information through scripting, but would be nice if I can have some guideline.

    Another thing is, have you thought about adding a prefix to your code? Something like ssSprite ( maybe that's too many s's ) to avoid the clash with other packages. Toolkit2D did this with tk2d prefix and I think it looks really clean and work well, considering namespace isn't available in Unity yet.
     
  15. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    At the moment the class handling atlas creation makes extensive use of Editor only methods. However, it would be possible to create class for building sprite-sheets at run-time, as the meat and potatoes of the operation (`Texture2D.PackTextures`) is available at run-time. I'll look into adding that functionality sometime later this week.

    As for prefixing, yes, that's a smart idea. It would also give me an excuse to rename things in a more consistent manner.
     
  16. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    does this handle 2D animation? :O I would be amazed if it did.

    Thanks for the contribution to the community!!

    Thanks,

    Scott.
     
  17. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,568
    I've only messed with it a little bit so far, but it looks like it can. The package comes with AnimationEditor.cs script
     
  18. lukke

    lukke

    Joined:
    Apr 23, 2012
    Posts:
    1
    The animation tools are quite intuitive.
    Adding frames by dragging and dropping is quick. Fine tuning the animation clip is easy too, thanks to the frame editor.

    I had a few problems though. I'm a total beginner so I might have missed the obvious.

    - In the Atlas editor, I can't change the Sprite Sheet target folder otherwise the export process bar will freeze while exporting. Is the relative location of this folder towards the other elements crucial ? The SpriteSheets folder is created at the root of the project could it be the problem ?
    I had one Sprite for which I had to press "find texture" and "find material" buttons each time before running the preview. Just selecting any other object would make the Sprite loose the references.

    - I've run into "IndexOutOfRange" errors while trying to instantiate prefabs with Sprite component sharing the same Atlas. A bullet and a bomb in a Weapons Atlas for example. Do I have to make them unique with the "Unique" button ? I tried but still didn't worked.

    I've tried my hand at Ludum Dare this weekend and your utility is great. If not for the last hours riddled with the aforementioned errors it would have been total heaven !
    Thanks a lot for sharing your tools !
     
    Last edited: Apr 23, 2012
  19. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    This was a failed experiment on my end- I thought it would be nice to have a select folder window pop up and set the directory for you. Unfortunately, `EditorUtility.GetDirectory` returns an absolute path, which the texture packer doesn't like. I've fixed this in the repository, and will update the package with this change reflected.

    As for the sprite that perpetually lost it's references, I'm not sure what the issue there is. Was it a single sprite or were all of the sprites behaving in a similar manner?

    The easy answer to this is that SimpleSprite doesn't really work well with the typical methods of Instantiation. I'm in the midst of adding a new class ("NewSprite.cs") that will handle this for you. It's taking a bit longer to implement because I'm simultaneously reworking the way spritesheet data is stored, but I'm expecting it to be functional within a week or so.
     
  20. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,568
    I'm having a hard time figuring out how to use the tilemapper. How do I actually paint the tile in the scene?
     
  21. GeneralV

    GeneralV

    Joined:
    May 29, 2012
    Posts:
    21
    Still working on this? I'm loving it for building levels, if nothing else. Othello has a much better way of handling animated sprites (or at least, much more intuitive. No documentation hurts ya here ;P )
     
  22. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Hi GeneralV,
    I work on it bits here and there, but in general (pun!) I'm not dedicating much time to this project (none of my current projects utilize sprites, and I'm getting pretty busy with the 9-5). I'd like to take this opportunity to again point out that it is open source, and I'd be more than happy to get some fresh eyes working on the project!

    However, if you have any questions I can typically answer them fairly quickly (either post in this thread or pm me).
     
  23. gregmax17

    gregmax17

    Joined:
    Jan 23, 2011
    Posts:
    186
    Ditto
     
  24. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    This feature is still very much unfinished, but I suppose I could record a quick demo to get you started. I'll try to get that done tomorrow.
     
  25. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Here' s a demo video walking through the Spritesheet creation process for use with the TileManager, and the building of a basic level with the Tile tool.

     
  26. Endarire

    Endarire

    Joined:
    Jul 3, 2012
    Posts:
    14
    How do I install this plugin/program?
     
  27. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    You may download a Unity package file from the Google Code page, here. To install, simply drag the unitypackage file into your project and double click.
     
  28. Souliloquy

    Souliloquy

    Joined:
    Jul 23, 2012
    Posts:
    5
    Thanks Karl, I'm using this in a game prototype and it works great.

    I had the need to get a callback whenever an animation cycle is completed so I made the following changes: (in case anyone finds this useful... here's more info about C# events: http://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx )
    Added to the top of Sprite.cs:
    Code (csharp):
    1.                                
    2.     public delegate void AnimationEndOfCycle(int wrapMode);
    3.     public event AnimationEndOfCycle EndOfCycle;
    4.  
    and then added a new private method (Sprite.cs):
    Code (csharp):
    1.  
    2.     private void NotifyEndOfCycle() {
    3.         if (EndOfCycle != null)
    4.             EndOfCycle(animation_wrap[currentAnimationIndex]);
    5.     }
    then call it in two places (Sprite.cs):
    Code (csharp):
    1.  
    2.                 if(currentFrame > animation_frames[currentAnimationIndex].y)
    3.                 {
    4.                     switch(animation_wrap[currentAnimationIndex])
    5.                     {
    6.                         case 0 : // Once
    7.                             currentFrame = (int)animation_frames[currentAnimationIndex].y;
    8.                             isPlayingInternal = false;
    9.                             break;
    10.                        
    11.                         case 1 : // Loop
    12.                             currentFrame = (int)animation_frames[currentAnimationIndex].x;
    13.                             break;
    14.                            
    15.                         case 2 : // Ping Pong
    16.                             currentFrame = (int)animation_frames[currentAnimationIndex].y - 1;
    17.                             posneg = -1;
    18.                             break;
    19.                     }
    20.                     notifyEndOfCycle(); // Here
    21.                 }
    22.                 if(currentFrame < animation_frames[currentAnimationIndex].x)
    23.                 {
    24.                     switch(animation_wrap[currentAnimationIndex])
    25.                     {
    26.                         case 0 : // Once
    27.                             currentFrame = (int)animation_frames[currentAnimationIndex].x;
    28.                             isPlayingInternal = false;
    29.                             break;
    30.                    
    31.                         case 1 : // Loop
    32.                             currentFrame = (int)animation_frames[currentAnimationIndex].y;
    33.                             posneg = -1;
    34.                             break;
    35.                        
    36.                         case 2 : // Ping Pong
    37.                             currentFrame = (int)animation_frames[currentAnimationIndex].x + 1;
    38.                             posneg = 1;
    39.                             break;
    40.                     }              
    41.                     notifyEndOfCycle(); // And here
    42.                 }
    43.  
    In my use case I'm actually using JavaScript for the main avatar controller so I made a helper class that listens to the event and communicates with the controller via messages (infrequently):
    Code (csharp):
    1.  
    2. public class Climber : MonoBehaviour {
    3.    
    4.     public float XOffset = 2.0f;
    5.     public float YOffset = 4.0f;
    6.    
    7.     bool rightSide;
    8.     Sprite sprite;
    9.        
    10.     // Initialization
    11.     void Start () {
    12.         sprite = GetComponent<Sprite>();   
    13.     }
    14.    
    15.     // event handler (Sprite)
    16.     public void ClimbEndOfCycle(int wrapMode) {
    17.         //Debug.Log("Climbing");
    18.         Vector3 pos = transform.position;
    19.         pos.y += YOffset;
    20.         if (rightSide)
    21.             pos.x += XOffset;
    22.         else
    23.             pos.x -= XOffset;
    24.         transform.position = pos;
    25.        
    26.         // Remove the event delegate
    27.         sprite.EndOfCycle -= ClimbEndOfCycle;
    28.        
    29.         SendMessage("ClimberDone");
    30.     }
    31.    
    32.     // message handler (AvatarController)
    33.     public void EnableClimber(bool right) {
    34.         rightSide = right;
    35.         // Add the event delegate
    36.         sprite.EndOfCycle += ClimbEndOfCycle;
    37.     }
    38.  
    39. }
    40.  
    Cheers
     
    Last edited: Aug 8, 2012
  29. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    is it flash compatible?
     
  30. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Very cool! I'll incorporate this into the next release (whenever that happens to be).


    It probably could be with a few minor changes, but out of the box no. I think the only thing preventing compilation is that I reference `CultureInfo` in the `ssTools` class (which is not supported on Flash), but I'm not positive.
     
  31. xhidnoda

    xhidnoda

    Joined:
    Nov 6, 2012
    Posts:
    23
    cool..!!! this is like 2d toolkit?
     
  32. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Kinda, except not actively developed and probably nowhere near as stable or feature rich. It is free though, and you get the source!
     
  33. xhidnoda

    xhidnoda

    Joined:
    Nov 6, 2012
    Posts:
    23
    Karl_ you have any game or beta-game make with this tool?
     
  34. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464