Harald

We are happy to announce support for Unity sprite masks and Unity UI rect masks in our spine-unity runtime! Check out the details in this blog post:
Blog: Unity SpriteMask and RectMask2D support

SpriteMask:


RectMask2D:
User avatar
Harald

Harri
  • Posts: 1111

vzlomvl

Looks amazing. It's time to change the UI from Mash to RectMask2d. :rock:
User avatar
vzlomvl
  • Posts: 57

altaf navalur

Hi,
I am trying to achieve the mask effect, but not able to get masking to work. Do you have any sample project or step by step instruction on how to setup the hierarchy in Unity for masking to work?

Regards,
Altaf
altaf navalur
  • Posts: 6

Harald

I have now added an additional example scene SpriteMask and RectMask2D to the spine-unity unitypackage under Spine Examples/Other Examples.

You can download it here as usual:
Spine Unity Download

Please let us know if it helped you with resolving your problem.

In general: please note that RectMask2D is for UI elements (SkeletonGraphic) and SpriteMask for non-UI elements (SkeletonAnimation and SkeletonMecanim). This is general behaviour in Unity, treating UI elements differently from non-UI elements such as Sprites.
User avatar
Harald

Harri
  • Posts: 1111

altaf navalur

Hello Herald,
The example project helped me achieve what I wanted. Thank you!

Regards,
Altaf
altaf navalur
  • Posts: 6

Harald

Great to hear, thanks for letting us know!
User avatar
Harald

Harri
  • Posts: 1111

altaf navalur

Hi Harald,
I am running into another issue now. We have the spine character on top of ScrollView. Now the clipping isnt working as expected. It works fine if I disable the mask in "Viewport".

I have attached two screenshots one with mask enabled in viewport & another one with mask disabled.

Any suggestions on how to achieve clipping of the spine character & Scrollview clipping.

Regards,
Altaf
You do not have the required permissions to view the files attached to this post.
altaf navalur
  • Posts: 6

Harald

Hi Altaf. Which skeleton and mask components are you using? Are you using SkeletonAnimation/SkeletonMecanim and SpriteMask or SkeletonGraphic and RectMask?
User avatar
Harald

Harri
  • Posts: 1111

altaf navalur

Hi Harald,

We are using SkeletonAnimation on the character & SpriteMask for masking.
On SkeletonAnimation mask interaction is set to "Visible outside mask". Visible inside mask doesn't work with Mask on my scroll view.
altaf navalur
  • Posts: 6

Harald

Unfortunately I still could not reproduce the problem. Could you please send us a minimal reproduction Unity project that still shows the problem as a zip file to contact@esotericsoftware.com? Then we can have a look at what's going wrong there.
User avatar
Harald

Harri
  • Posts: 1111

altaf navalur

Hello Harald,
I have sent you an email with a link to the test project.
altaf navalur
  • Posts: 6

Harald

Thanks for sending the reproduction project.

The problem is a combination of two things:
  1. You are mixing UI Canvas based components in the hierarchy with non-UI components such as SkeletonAnimation (Sprite would also be a non-UI component). This will cause problems or unintuitive behaviour in combination with the respective masks: SpriteMask is intended for non-UI components, Mask and RectMask for UI components.
  2. Even when the SpriteMask and SkeletonAnimation are correctly placed outside the Canvas hierarchy, the UI Mask of die UI element Viewport still affects sprites and the SkeletonAnimation's renderer. There you need a SortingGroup component on top of both the SpriteMask and all non-UI components (with Order in Layer set to 100 or higher), so that the masks don't interfere with each other. There are some nice examples on how to isolate mask effects on the SpriteMask documentation page.

Another potential solution could also be to have two cameras render the UI elements and the non-UI elements and non-UI-masks separately, but the above solution would be the preferred one.

I have sent you a corrected version of your scene via email.
User avatar
Harald

Harri
  • Posts: 1111

altaf navalur

Hi Harald,
Thanks you for looking into the sample project.

I wanted to keep the spine character under scrollview as we want it to scroll along with other UI elements. Without that we will have to manually handle scrolling

Regards,
Altaf
altaf navalur
  • Posts: 6

Harald

You just need to create a script that copies the respective Transform.position over to the GameObject outside.
User avatar
Harald

Harri
  • Posts: 1111


Return to Unity