- Home /
Masking 3d Mesh in a UI ScrollRect
I am trying to add 3d objects to my UI scroll rect? But i am not having any luck masking them out. Is this possible?
Answer by RChrispy · Sep 30, 2015 at 07:17 AM
Well in the reference there are pictures of it happening!
http://docs.unity3d.com/Manual/script-Mask.html
But this may be only a picture because in the text it says : "Image". :/
EDIT:
I tried things out and unity only masks image components! Not the render.
http://fs5.directupload.net/images/150930/e8o8i95i.jpg
But you can render to texture with a 2nd camera. ( Only this camera can see the object. And then store this in an Image component, wich has the mask applied on! ;)
Cheers
Well i could work...But i dont know if i am doing something wrong or if it's just not optimal. I have basicly alot of buttons on a scroll rect. each button should have a 3d object on it. So the second camera should only show the 3d object. in the right size and on the right button. i dont want to set up a "stage with alot of cameras, fil$$anonymous$$g induvidual objects and then projecting them on to the right button
You only need a second camera with the perspective you want to see and render the whole perspective to 1 single image. This image gets passed to an image component and this gets masked.
If you see there all button / 3d Objects of your scene they will get masked with the image if its placed right. Thats the only solution I can come up with.
ps: if you use only the uGUI elements for your game you can make the 2nd Camera orthographic and calculate the mask rect to camera. That and then render it on the main screen. that way your camera on its own is a mask for 3D objects.
yep....i have to mess around with it. I have asked questions if there is away to modify the standard shader so that it is supportet by the UI masking system...The word "stenceling" seems to come up alot..but shaders is not my strong side
Answer by Rodrysson · Nov 04, 2018 at 03:28 AM
Hello! I bring a simple solution here. https://answers.unity.com/answers/1568533/edit.html I hope it work for you :D
Correct link :D https://answers.unity.com/questions/998203/