Hi all, I was wondering if there's a way to clip sprites easily in Unity 4.3's new 2D system. For example, lets say I have these 2 assets in a sheet: And I want to animate the leaf's rotation inside the green rectangle: I suspect that it's not possible, which means I would need to use a classic spritesheet animation, which is too bad, since with Unity's animation system, I could have the leaves animation's "strength" to correspond to how hard the block was falling on the ground, for example... but I thought I'd ask here first Any ideas would be much appreciated. Thanks!
Nobody has any ideas? Bummer... I really hope the Unity devs add this functionality (and an overall simple way to do clipping masks in Unity, instead of workarounds using planes and shaders that is difficult to get to work correctly). I love Unity, don't get me wrong But it seems they simplified a LOT of things, I'm just surprised they didn't simplify that specific aspect.
I think this may be possible. If you have the leaves be hollow. Then in the animation for the leaves have that tile you want them to clip with in the back as they rotate and / or fall. Will this give you the desired result?
Im a N00b, sorry. Im just theorizing. Leaf can Rotate around Z? Leaf might need a black and transparent Texture Mask, that a custom Shader will use? ex: Problem: Passing in the Rotation to the Shader and having the shader use that rotation to rotate the Black and Transparent Mask... and offsetting it. I guess the shader needs to be given the mask uv offsets as well. I guess you would have to get the Angle... background plane compared to a Leaf and use that for the Masks rotation in the shader?!? I have no idea if a shader can rotate masks or how that works... But i would try that way 1st. :/ maybe use: http://wiki.unity3d.com/index.php?title=DepthMask
You can do this if you use NGUI and just add a panel turn on clipping, then add your leaf as a sprite inside the panel and add a script to rotate it. I would use the spin script as its already made. However this only works inside rectangular shapes. I would like to be able to do clipping inside any path shape. I hope they add the ability to do this soon because it would be really helpful if for doing tiled animations inside unity that you might want to clip with an irregular shape. I looked into depth mask but it seems way more complicated to do.
FYI you can also do this with 2Dtoolkit. It definitely works inside rectangular clipping areas, but I haven't tried to create irregular clipping areas yet.
I know this thread is dead, but I have found success using a Stencil Mask Shader on your background and a Stencil Draw In Mask shader found in this thread: http://forum.unity3d.com/threads/is-it-possible-to-clip-a-sprite-with-another-sprite.254144/ It has the code necessary to attach to your materials