Search Unity

[DEPRECATED] Anima2D - Advanced 2D Skeletal Animation Plugin

Discussion in 'Assets and Asset Store' started by sergi_mandarina, Nov 21, 2015.

Thread Status:
Not open for further replies.
  1. EvaDeli

    EvaDeli

    Joined:
    Feb 6, 2017
    Posts:
    1
    I really like Anima2D. Its a great way to animate 2D art in Unity. Here is some of my work done with Anima2D https://goo.gl/m3TkCP
     
    Sergi_Valls likes this.
  2. Kumokishi

    Kumokishi

    Joined:
    May 26, 2017
    Posts:
    1
    (response to this)

    Hello I just want to check whether I understand this right but, does this mean we are not going to be seeing FFD in Anima2D ever, or just not anytime soon? As I understand it's something you guys are still working on, or did I miss some information somewhere? Sorry for the confusion, thanks
     
  3. kostet1977

    kostet1977

    Joined:
    Mar 30, 2015
    Posts:
    11
    I dealt with mesh duplication, thank you. But now another issue.
    Trying to use spring bones I've got tones of error messages.
    upload_2017-5-26_22-10-9.png
     
  4. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    We are not working in FFD for Anima2D. We only keep Anima2D working across Unity versions and fixing bugs that may appear.

    I do not provide support for SpringBones because it is not an Anima2D feature, just an example of procedural animation. Scripts inside Examples were added to illustrate the examples and are not bulletproof. There are some tutorials in youtube about how to setup SpringBones.
     
  5. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    173
    Wildness is some kind of ... It looks like it's buying up the rights, the plug-ins necessary for all useful and developing before, especially to stop their development. And the authors after that can not say anything intelligible about what is happening, in addition to the standard words allowed by the agreement.
    There is no native bone (and FFD!) animation in 2D, according to the roadmap - it's not developed yet, but Anima2D will now remain incomplete forever! Great... :(
     
    Kale likes this.
  6. filestream

    filestream

    Joined:
    May 22, 2017
    Posts:
    3
  7. JohnSmith1915

    JohnSmith1915

    Joined:
    Apr 21, 2016
    Posts:
    143
    Any way to get dynamic lighting with Anima2D like can make Dragonbones in Untiy?
     
    Last edited: Jun 3, 2017
  8. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Anima2D;
    4.  
    5. [RequireComponent(typeof(SpriteMeshInstance))]
    6. [ExecuteInEditMode]
    7. public class TextureOverride : MonoBehaviour
    8. {
    9.     [SerializeField]
    10.     Texture2D m_TextureOverride;
    11.     public Texture2D textureOverride
    12.     {
    13.         get { return m_TextureOverride; }
    14.         set { m_TextureOverride = value; }
    15.     }
    16.  
    17.     SpriteMeshInstance m_SpriteMeshInstance = null;
    18.     SpriteMeshInstance spriteMeshInstance {
    19.         get {
    20.             if(!m_SpriteMeshInstance)
    21.             {
    22.                 m_SpriteMeshInstance = GetComponent<SpriteMeshInstance>();
    23.             }
    24.             return m_SpriteMeshInstance;
    25.         }
    26.     }
    27.  
    28.     MaterialPropertyBlock m_MaterialPropertyBlock;
    29.     MaterialPropertyBlock materialPropertyBlock {
    30.         get {
    31.             if(m_MaterialPropertyBlock == null)
    32.             {
    33.                 m_MaterialPropertyBlock = new MaterialPropertyBlock();
    34.             }
    35.  
    36.             return m_MaterialPropertyBlock;
    37.         }
    38.     }
    39.  
    40.     void OnWillRenderObject()
    41.     {
    42.         if(textureOverride)
    43.         {
    44.             spriteMeshInstance.cachedRenderer.GetPropertyBlock(materialPropertyBlock);
    45.  
    46.             materialPropertyBlock.SetTexture("_MainTex",textureOverride);
    47.  
    48.             spriteMeshInstance.cachedRenderer.SetPropertyBlock(materialPropertyBlock);
    49.         }
    50.     }
    51. }
    52.  
    You need to create your own shaders. There is one example in the Examples folder.
     
  9. filestream

    filestream

    Joined:
    May 22, 2017
    Posts:
    3
  10. Kale

    Kale

    Joined:
    Aug 25, 2011
    Posts:
    103
    I guess FFD is now off the table.
     
  11. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Hi Sergi, 2 questions:

    1) After creating sprite meshes out of the sprite rects in atlas, the sprite rects IN ATLAS (not in spritemesh (Editor)) become "extruded" by few pixels. That would be okay, however sometimes i need to revert back specific sprite rect to its original state, so i delete the sprite mesh in question, that allows me to again modify the sprite rect in original atlas (as there is no connection to spritemesh anymore). However the sprite rect is left extruded, and i dont remember its original bounds. So converting to sprite mesh seems destructive to original sprite atlas - or is there a correct way to get back to an original sprite rect AFTER spritemesh has been created?

    2) I've read in your previous post to use Mesh Type "Tight" and NOT "Full Rect". In my case, i have whole game in 1 huge atlas, and some of the assets, that are not character assets, need their rect at "Full Rect". Would you in such case use separate atlas for Anima2D characters? Or a separate atlas per each Anima2D character? (i think that means if the shader etc are the same for all atlases, i would get 1 extra draw call per atlas/character (possibly more due to layer order), yes? What would your general recommendation on this be? Is "Tight" necessary for Anima2D?

    Thank You
     
    Last edited: Jun 15, 2017
  12. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    dos that work with a 2.5D or isometric camera?
     
  13. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    1) The rect is computed based on the geometry you create in the SpriteMesh (and yes, it is also a bit extruded). If I don't modify the rect and make it large enough to fit the geometry I cannot override it. So I guess yes, creating a SpriteMesh is a rect destructive operation. Can you explain me your use case that makes you create and delete a spriteMesh?

    2) Use separate atlases for your Anima2D characters. Anima2D uses SkinnedMeshRenderers for skinning and they don't batch. You will always get 1 draw call per SkinnedMeshRenderer. Packing everything in one atlas will not give you any benefit. Check the scenes with combined characters to make them render in 1 draw call. Still you need the SpriteMeshes to fit in the same texture.

    It should work well using perspective/orthographic cameras. If you have any specific setup that does not work with Anima2D just let me know.
     
  14. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sergi,

    Thank you for your replies!

    A) Most important is to know that i understand the nature of the extrusion, and you expained it very well. So we can count this point as answered. Anyways, the reason i sometimes have to remove/recreate existing spritemesh is that i dont have under control the creation/positioning of the sprite rects/their size, as its done in another program. So in case i need to later (after creating the meshes once) add lets say a "hat" to the atlas, or the size/gfx of existing hat chages, the sprite rect position/or size/or both may change, and i will have to remake the sprite mesh(es). Full disclosure - i am not at this point yet, its just my assumption this might interfere with the workflow - i was thinking keeping the rects (except the ones that changed) and redrawing by had the ones that changed - i was only importing only the atlas texture, not using atlas.xml file that defines the new rect positions as i did not have program for that yet - only using photoediting to manually draw my atlas - ans then using Unity's sprite editor to cut the texture - create the rects)) - however im now already using a tool that exports both texture and xml, so my previous assumption might be invalidated (as i get fresh xml with rect data any time anything changes, and i can reimport the correct rects) - sorry - this point should not be an issue now (i think! still dont know tho.... IF all the rects change their position when i repack, then i would need to recreate all the spritemeshes with their bones etc? dont know, didnt test yet!)

    B) Your SkinnedMeshCombiner port is amazing! I love it! And yes, i understand now what you mean after i used it myself. So we cant batch the combined meshes together, since they are created dynamically during runtime? I understand it now, i can see each combined mesh requires 1 draw call. Or is it possible for us to tell Unity somehow that the combined meshes are using the same atlas texture, same shader, material, etc and somehow manage to batch them (in theory?). Just wondering, if there would be a theoretical hack i could perhaps investigate later on (1 draw call per combined mesh is still awesome, but maybe one day i'd like to push the performance further with many animated characters). Just a short brainstorm/opinion from your side would be awesome!

    Thank you!
     
    Last edited: Jun 18, 2017
  15. Kaizine12

    Kaizine12

    Joined:
    Jun 21, 2017
    Posts:
    4
    Greetings.

    I don`t really know where to place this but I need some help regarding some sort of bug I found while bouncing this one character between 2 different projects. It`s a bit urgent.
    View attachment 235640

    And

    View attachment 235641


    Notice how the highlighted spots look sharply weighted on the 2nd image. The first image was imported to an empty Unity project with only the Anim 2D asset pack and the respective character images, from the 2nd image project (in which all of the weighting and boning was done in) which is a project in a Git folder which has all of the team`s assets and scripts in it, as well as Anima 2D and Ferr 2D.

    Both characters have the exact same assets, bone settings, and weights.

    Does anybody have any idea why this is happening or how to handle it?
    I will be posting this in Unity Support and the Anima 2D thread.
    Thank you in advance.

    Happy developing :)
     
  16. Fychan

    Fychan

    Joined:
    Jun 22, 2017
    Posts:
    1
    When putting your two images one over the other it seems the head bone is slightly rotated. Check the rotation of the bone in the inspector to check if theyre really in the same position

    upload_2017-6-22_17-54-26.png

    Now for my question:
    Has anyone been able to use the auto weight when creating Sprite Meshes? It hasn't worked at all for me lately, at least not when there's more than one bone. Is it just with me or is it a bug of the latest version?
     

    Attached Files:

  17. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    A) All I can say is use Unity's Atlases :)
    B) Right now 2 skinned mesh renderers cannot batch. With that limitation in mind, I would not try hacks and try one draw-call per character using the mesh combiner. I you face performance issues, then think about hacks.

    Can you send me both penguins in simplified repro-projects?


    No code has changed related to that. Make sure the bones are inside the mesh.
     
  18. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sergi,

    Thanks for your replies!

    Regarding your suggestion to use Unity's Atlases - well i tried that approach (Sprite Packer), but somehow i didnt like it as much as using external tools, simply because the atlas is (from what i could see) created "under the hood", sure you can specify your own packer policy, but not seeing the atlas or having what i would consider a better control over the output, for example i experienced it put the sprites into different pages etc when it shouldn't have had done that (there are still some bugs in issue tracker regarding this bug afaik - but then again this is not as much Anima2D related).

    Best regards!
     
  19. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sergi,

    I have a question. For the moment i was using 1 atlas for everything in game, including Anima2D characters. Im about to transition splitting it into 2 Atlases, one for a single character, another for the rest of stuff

    My question is: When doing this kind of adjustments, do i have to COMPLETELY remake all the bones, spritemeshes and animations? Graphics are the same. Sprite rectangles are the same, but their positions will change and there is a new atlas. This is the kind of changes i am interested in - can Anima2D can handle them somewhat effortlessly, or is as much time involved, as rigging + animating the whole character again.
     
    Last edited: Jun 23, 2017
  20. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    1) Set your new Sprite into your SpriteMesh via Inspector.
    2) Open SpriteMeshEditorWindow.
    3) Select all vertices and move them to match the new Sprite.
    3) Move the pivot point to bring the bind poses in place.
     
  21. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sergi,

    Awesome and thanks again!

    So the transition has been successful. Here are some points for further readers ive noticed, feel free to correct me:
    1) Disable your Skinned Mesh Combiner during the transition from N->N+1 atlases, it doesnt show spritemeshes correctly when they are from more than 1 atlas.
    2) You will still have to re-slice/tesselate your spritemeshes (and move the new sprite shapes, as Sergi mentioned pt [3], this isnt so bad) one by one if you're about to use new atlas. Vertex copy between SpriteMesh atlases would be nice (but this needs to be only done once as long as you keep character in your new atlas).

    This plug is awesome, can't wait for full unity integration in the near future!
     
    Last edited: Jun 24, 2017
  22. FaunaGames

    FaunaGames

    Joined:
    Mar 23, 2017
    Posts:
    5
    Hello @Sergi_Valls ,

    What is the best practice to combine a 2D IK character mesh to keep sorting layers. It seems skinned mesh combiner breaks sorting order that makes it useless when animating a 2D IK character.

    Best Regards,
     
  23. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sorry to interject, i've solved this problem on my end and am going to just post a related link (involves adding few lines of code into SkinnedMeshCombiner, or even better, if you like to do it properly, make a custom inspector for it, to have the Sorting Layer combobox and Sorting Order input box):
    http://answers.unity3d.com/question...order.html?childToView=1366701#answer-1366701
     
    FaunaGames likes this.
  24. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    First of all make sure you set the list of SpriteMeshInstances in back-to-front order in the Combiner. After this you should have your character displayed correctly. After this you can set the sorting layer and order of the generated skinned mesh renderer like _watcher_ said. I'll maybe include this in next update.
     
    FaunaGames likes this.
  25. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Absolutely would send you the SkinnedMeshCombinerCustomEditor + SkinnedMeshCombiner update i've made for myself; if you ever wanted it, just let me know, tho no doubt you can do it in 5min yourself ;). Cheers!
     
    FaunaGames likes this.
  26. Scrag3

    Scrag3

    Joined:
    Jun 25, 2017
    Posts:
    1
    I am having some trouble with binding bones to mesh in Anima 2D. Most of the parts work fine but when I try to bind one of the pieces it gives me this error. If I apply it and go back to the scene the sprite is then invisible. If I unbind the bone it then shows up again. Any help would be great.
     

    Attached Files:

  27. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    As you can see in the SpriteMeshEditorWindow, your mesh has no weights. The automatic computation failed probably because the small island separated from the main mesh. Delete those vertices and bind again.
     
  28. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Hi again)

    I saw this feature somewhere but cant seem to find it: Say i have basic IDLE, FALLING, JUMPING animations on a character - and need to add variation to group of joints - like slashing sword attack - as an override for that specific group of joints - and this would be an override for the hand joints (hand animation) for all 3 animations - IDLE, FALLING, JUMPING - how can i add that using Anima2D (or was it Unity Animator sub-blend tree or something / .. cant remember)? The other joints should behave as they normally would in case of IDLE | FALLING | JUMPING animation.

    UPDATE: Wait, is it the "avatar mask"? And do i need to use Mecanim with Anima2D? I'd love to see a link to a tutorial if anyone has any!
     
    Last edited: Jun 27, 2017
  29. FaunaGames

    FaunaGames

    Joined:
    Mar 23, 2017
    Posts:
    5
    Hello @Sergi_Valls , @_watcher_
    Sorting in SkinnedMeshCombiner's array works fine thank you.
    On the other hand, I loose ability of SpriteMeshAnimation when i combine all parts. ForExample blinking eye of character, changing mouth shape etc.

    Best Regards,
     
  30. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    This makes sense, and i suppose the only way to prevent this is to not combine the meshes you want to animate, and then only those that you dont mind having their sorting order to be higher/lower than the combined mesh. This means eyes could be left non-combined with sorting order higher than the combined mesh-es sorting order, if no other sprite mesh that would overlap the eyes from the combined mesh is expected to be higher sorting order than the eyes. Its a conjecture, if there is other/better way it would be nice is somebody else could comment. Also it would make sense that any spritemesh excluded from the combined mesh adds minimum of +1 draw call.

    UPDATE: In case the mesh in question that you need to animate does not need deformations - say the eyes - and say you have 2 sprites (eyes closed, eyes opened), then if you do not make sprite meshes out of these, but say you leave them in your shared atlas - where you would normally keep things not Anima2D related - and the sprites from this atlas are actually batched (which is awesome) - then say you take those 2 eye sprites and attach them to the bones of your character (usually this would be a head bone), and then you can activate/deactivate them in your animation (from code, or timeline) to have them closed/opened, then your bones would still move them to be in the right place, this would not produce an extra draw call since its in a shared atlas, would still have to respect sorting order though, and could not use SpriteMeshAnimation component.
     
    Last edited: Jun 26, 2017
    FaunaGames likes this.
  31. Kaizine12

    Kaizine12

    Joined:
    Jun 21, 2017
    Posts:
    4
    I apologize for my ignorance, but what exactly is a simplified repro-project, and how do I go about making one to send your way?
    Thank you for your support.
     
    Last edited: Jun 27, 2017
  32. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    GIT, SVN, or other online REPOsitory for your project, that keeps revision history of the changes you've made. If you never used one, its a good idea to start. If you ever worked in a team, its indispensable and pretty much required.

    To create a Github repo, follow this guide: https://guides.github.com/activities/hello-world/
     
  33. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    I just need a Unity project, with the minimum amount of files that reproduce your problem. You can make a zip file and send me a dropbox link by PM.
     
  34. Kaizine12

    Kaizine12

    Joined:
    Jun 21, 2017
    Posts:
    4
    Well I just went over this with our team and I`m afraid we can`t send the projects due to the fact we signed an NDA with the client... We will try to rule out any assets or scripts that are suspected to cause the problem. If its on our team`s code we should be able to send it after revision but if it has any of the client`s code in it it won`t be possible.
    Thank you so much for your patience though.
     
  35. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    A project with Anima2D, an empty scene with your character and your spriteMeshes should be enough to reproduce your issue. You can use white textures.
     
  36. gdevn1

    gdevn1

    Joined:
    Oct 13, 2015
    Posts:
    1
    I'm using Anima2D. I tried to reduce draw call. so I added Skinned Mesh Renderer Script on my character object. There was no problem in Scene View. But in play view, Order in layer is messed up. I think it ignores value of Order in layer, and draw images by Script Meshes Instances list order.

    Is this normal? If is not, how can I fix it?
     
  37. crocodilealonso

    crocodilealonso

    Joined:
    Apr 19, 2014
    Posts:
    1
    Hi, is it possible to modify or generate the sprite mesh in runtime? Let's say I'd like to add dynamic customizations to character's appearance, e.g. logo on shirt, custom glove, etc.. How would I do that?
     
  38. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    Yes, you need to sort your SpriteMeshes back-to-front in the list.

    There are several ways of doing that without generating anything at runtime. You can rig all the custom elements and enable/disable them when needed.
     
  39. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Sergi,

    correct me if im wrong, but as soon as the meshes are combined, we can not "change" (eg enable/disable parts like swap cloth pieces etc). And what you are trying to say is, that you can leave specific SpriteMeshes (like say a hat) separate (not include it in the Mesh Combine), set its Sorting order to be higher than the combined mesh (same layer for simplicity), and then enable it when you want to add a hat? But that means no "part" from the combined mesh (eg "left hand") should ever be expected to "overlap" the added hat (go "above" the hat), since it cant (it was combined and now resides at the lower order position). It also means that (if for ex we have hair, the sprite size should be smaller than the hat, otherwise it will stick from under the hat? We cant remove part of the combined mesh now, can we). Or am i missing something here? Can we do something better than this.
     
  40. Neo-Dragon

    Neo-Dragon

    Joined:
    Feb 29, 2016
    Posts:
    17
    This is probably a silly question but what's the way to get a single reference to the material on a SpriteMeshInstance rather than a shared material? I'm trying to do a simple shader color transition but it's affecting EVERY mesh with the shader at once (rather than one at a time).
     
  41. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    The question I was answering was not related to combining meshes. It is true that once you combine SpriteMeshes you lose the ability to manage them separately and all you mention has to be taken into account. My recommendation will always be to combine meshes only when the draw-call count is proven to be the bottleneck.

    You need to set a different material per SpriteMesh (Renderer). Renderers facilitate that by creating a clone of your material when calling the "material" property. SpriteMeshInstances only expose a sharedMaterial property. You can create an instance of that one and set it back using code.
    You can also make all your SpriteMeshInstances share the same material and set a different MaterialPropertyBlock. Check the TextureOverride in this page for an example.
     
    mentorgame1 and _watcher_ like this.
  42. mentorgame1

    mentorgame1

    Joined:
    Oct 31, 2016
    Posts:
    19
    I want apply 3D rotation animations similar to what happen on mario paper combined with anima 2D but the sprite don't rotate like the sprite component of the unity does. what can i do to be able to apply 3d rotation on the anim2D?
     
  43. lahcen-014

    lahcen-014

    Joined:
    Apr 7, 2017
    Posts:
    3
    i have one question also and sorry for ,my im very new with 2d just started .
    i have one question for now that i cant find any documentation or any tuto and i dont even if its possible
    the question is :
    I have an image png image and there is a character inside that i want to animate with skeleton but i have to slice the hand arms legs body parts so is it possible to cut the body parts of this character on this image and then use this part to animate it
    thank you very much
     
  44. FVL_

    FVL_

    Joined:
    Apr 10, 2017
    Posts:
    3
    Hello Sergi.

    I'm having an issue when baking animations. Everytime I disable the IKs after baking, the feet move very erratically.
    Tried in both simple and complex animations, it's always messed up when I disable the IKs.

    Edit:
    I noticed it's every other baked frame that gets messed up. One is right, the next one is out of place, and the next one is right again (and so on).

    Any ideas what the cause might be?

    SOLVED:

    It was caused by the animations being in "Legacy". Unchecking it and baking them worked perfectly.



    Thank you, keep up the great work.
     
    Last edited: Jul 12, 2017
    ram23 likes this.
  45. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Hi,

    Is there anyway to have the Unity SpriteMask work with Anima2d? We purchased a plugin which works, but we would rather use the native stuff if we can. The issue being that SpriteMask seems to only work with SpriteRenderer, and Anima2d creates spritemeshes.
     
  46. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    To rotate a skinned mesh you need to rotate the bone's transforms.

    Start by splitting your character into body parts. Use the SpriteEditor to slice them and use SpriteRenderer to draw them in the scene. Animate using the AnimationWindow. Once you are familiar with the workflow you can try Anima2D to achieve skinning deformation.

    Good to know you sorted it out. Baking animations is kind of broken in 2017.1. I am preparing a release to fix compatibility issues.

    Try this shader:
    Code (CSharp):
    1. Shader "Anima2D/SpriteMask"
    2. {
    3.     Properties
    4.     {
    5.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    6.         _Color ("Tint", Color) = (1,1,1,1)
    7.         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
    8.         [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
    9.         [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
    10.         [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
    11.         [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
    12.     }
    13.  
    14.     SubShader
    15.     {
    16.         Tags
    17.         {
    18.             "Queue"="Transparent"
    19.             "IgnoreProjector"="True"
    20.             "RenderType"="Transparent"
    21.             "PreviewType"="Plane"
    22.             "CanUseSpriteAtlas"="True"
    23.         }
    24.  
    25.         Cull Off
    26.         Lighting Off
    27.         ZWrite Off
    28.         Blend One OneMinusSrcAlpha
    29.  
    30.         Pass
    31.         {
    32.             Stencil {
    33.                 Ref 1
    34.                 Comp Equal
    35.                 Pass Keep
    36.             }
    37.  
    38.         CGPROGRAM
    39.             #pragma vertex SpriteVert
    40.             #pragma fragment SpriteFrag
    41.             #pragma target 2.0
    42.             #pragma multi_compile_instancing
    43.             #pragma multi_compile _ PIXELSNAP_ON
    44.             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
    45.             #include "UnitySprites.cginc"
    46.         ENDCG
    47.         }
    48.     }
    49. }
    50.  
     
    sakataharumi likes this.
  47. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Sorry, I just want to be clear about what you want me to do. That would go on the parent gameobject which should mask all child gameobjects? Will that work with both sprites and spritemeshes, or only spritemeshes? Or have I misunderstood completely? :)

    By the way, thanks for the reply. I told our artist to hold off on masking until I find out if we should use a 3rd party or something built in ... so this is much appreciated. The less 3rd party assets that go into game and combine together the safer it is to manage over time ...
     
  48. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    -You need to create a new shader file (Assets->Create->Shader->(Any shader type will do).
    -Open it with a text editor.
    -Delete all the code.
    -Paste the code I posted and save.
    -Create a new material.
    -Inspect the material and select the shader located at "Anima2D/SpriteMask".
    -Set the material to all the SpriteMeshInstances that need to interact with a Unity's SpriteMask.
     
  49. korbul

    korbul

    Joined:
    Jan 20, 2014
    Posts:
    16
    Hello, we are using anima2d to develop a game.
    Our artist made a character and exported it piece by piece (not as an atlas). Then the character was imported in unity, was made into sprite mesh and animated.
    Later on we figured that having the character's each individual part in a separate png takes to much space, so I assigned a packing tag for each png and turned on the Sprite packer.
    The sprites are now packed into an atlas and it looks like the meshes in the scene are using the packed textures. I know this because one of the texture has another piece bleeding into its texture as seen in the attached image. (with packing turned off that bleed is not present)
    Capture.PNG

    Now for the problem. When i make an android build with a simple scene (just the guy in the image), both the atlas and the individual png files are added to the build. This is obviously a big issue. We need to save space.

    I've attached another image with the build log illustrating the issue
    Capture2.PNG

    I spent several days trying to figure this out. One of the things I tried was to take the individual png files and use an external tool to make an atlas from them (i made sure to keep their dimensions in the atlas, even the empty space) Then imported the atlas in unity, wrote a script to slice the items to their precise dimensions as before and then tried to input these new sprites in the existing sprite mesh. Sadly this did not work. It looks like anima2d tries to keep the previous sprite meta data and puts the vertices at 0,0 even though the sprite is sliced at the correct location.

    Capture3.PNG

    I also tried to use the sprite atlas (the new packing system in 2017.1). No luck as well. Still same problem.
    At some point I though this is caused by the reference to the sprite in the sprite mesh. So I modified the code so that the sprite mesh takes a sprite atlas and then i would select the sprite from the atlas (i modified some editor files to make this work). sadly the entire anima codebase is too large and failed in my attempt.

    I really don't want to loose the days the artist put in to bring in all these characters and animate them.
    Is there a solution to use some sort of packing and keep all that has been done?

    PS. tried this using unity 5.6.2f1 and unity 2017.1.0f3. Current anima version is 1.1.2
     
  50. La-Spada

    La-Spada

    Joined:
    Apr 10, 2015
    Posts:
    1
    Can I copy and assign the skeleton to another character, in order to have two characters with the same animation? I am trying to follow the tutorials, but I can't figure out how to make it work.
    Thanks
     
Thread Status:
Not open for further replies.