- Home /
Can I break the UI MASK hierarchy?
I'm using unity 4.6. I saw a couple of UI masks tutorials and saw that there's a certain hierarchy I can't seem to break:
-Canvas
--- Panel (holds the mask component)
--------Image
I want to move the mask and leave the image in its place.
(Attach the mask to a moving object, and by that, exposing the image by the moving object position)
I have 2 problems with it:
My moving object barely moves my mask (I guess because of the canvas).
The image is a child of the mask, so even if it will move, it will move with it.
Can I even do it?
Answer by m_pangolin · Dec 31, 2014 at 08:38 AM
I Solved it by detaching the image from the mask parent, move the mask, and then reattach it (Set the image's parent to the canvas and after moving the mask set it to be the image's parent again). That way the image stays still and the mask is slowly revealing the image.
I tried this and it did not work. Could you explain a little more for me please? I am very interested in this!
Answer by tayl0r · Jul 15, 2017 at 12:09 AM
You can actually do masking without using direct ancestors. Setup your hierarchy like so:
- left mask (Image)
- right mask (Image)
- mask parent (Image + Mask + this object should be 0 size because you dont actually want its mask to be applied)
- child object that gets masked
- child object that gets masked
- child object that gets masked
Once you set it up like that, you have to go into 1 of your child objects and toggle the rendering component on and off to refresh the masking setup.
Tested in Unity 5.2.2p4
Your answer