Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by dylanHart · Aug 03, 2016 at 09:28 PM · uicanvasclipping

RectMask2D.RemoveClippable(IClippable clippable) doesn't seem to work. Am I using it correctly?

I have a RectMask2D UI object with two Image objects as children. It works great: both the images get clipped to the object's rect.

Goal: I want the mask to NOT clip the second child, while keeping the same parent-child hierarchy.

Issue: Calling rectMask2D.RemoveClippable(IClippable child2Clippable), child2 still gets clipped.

Am I not understanding the purpose of this method, or are there other methods that I need to call afterwards? Has anyone else experienced this? I've tested this in 5.3.3 and 5.4.0. The most relevant information I was able to find is a bug that I presume has been fixed already ( http://forum.unity3d.com/threads/ugui-5-2-rect-mask-2d-has-bug-be-careful.391040/ ).

Edit: Found MaskUtilities.NotifyMask2DStateChanged(RectMask2D mask) the other day while troubleshooting with a friend. Tried calling this with the mask reference passed in after callling RemoveClippable(), but child2 still gets clipped.

Just FYI: I have a single RectMask2D in this scene, so I'm positive there isn't a separate mask somewhere also clipping child2.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by dylanHart · Aug 06, 2016 at 01:28 AM

Ah, I see now! RectMask2D, as @Bunny83 pointed out, isn't designed at all to be a very complete masking solution. I'd actually prefer it to be named something like QuickMask2D, or maybe mention in the docs why it exists. Anyway, handling IClippable components manually seems to be the way to go.

Below is basically what I'm doing now, and it seems to be fantastic for my purposes. Any further information would be appreciated. I'm bummed out that I couldn't find info on this stuff from searching the docs, but now that I understand IClippables, maybe I'm good to go.

 private void SetClipping()
     {
         // get all the clippables in some object's children
         foreach(IClippable clippable in someObject.GetComponentsInChildren<IClippable>())
         {
             // call SetClipRect on the IClippable, but only if it's one of the objects you want to clip
             if (someCriteria) clippable.SetClipRect(myMask, true);
         }
     }

I guess alternatively you could use the second parameter of SetClipRect to pass in your criterion bool and not have the if statement, if that's what you're working with. Thanks again @Bunny83 for a nudge in the right direction.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bunny83 · Aug 05, 2016 at 11:29 PM

You can't do that because "MaskableGraphic" automatically registers (using AddClippable) and removes (RemoveClippable) itself from the parent mask. That is the point of the methods. They are part of the automatic process. MaskableGraphic has a private method called "UpdateClipParent" which is called by several callbacks. It automatically searches for a RectMask2D component on a parent and adds itself to the mask.

That's the point of RectMask2D. It serves as mask for it's children. If you don't want to mask it, don't make it a child of it.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dylanHart · Aug 05, 2016 at 11:33 PM 0
Share

Thanks! That's disappointing. I guess I'll have simulate the parent/child hierarchy with transform references.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Is there a clipping distance for UI elements? 1 Answer

Change size of UI canvas image, the best option? 1 Answer

Screen Space - Camera Bug (Buttons does not work) on Unity 2017 0 Answers

New UI(=uGUI) depth problem with particle 0 Answers

How to set the UI Text position to be relative to his "grandfather" prefab 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges