Is there a way in Unity3D to detect that a gameobject is on top of a pillarbox in order to avoid rendering it
Is there a way in Unity3D to detect that a gameobject is on top of a pillarbox in order to avoid rendering it
I am currently developing a 2D Unity game.. At the moment I was able to implement a code that allows the camera to keep the aspect ratio which is initially 16:9 and when the aspect ratio is different it will add the letterbox perfectly. My issue is that I have a HUD that can be hidden by the player, so when I have letterbox implemented the HUD is not hiding properly.. I've spent heaps of time trying to find an answer but I haven't been able to.. Is there a way to avoid rendering/showing the part of the HUD that is on top of the letterbox.? I am attaching an image that shows how the HUD looks normally and how it is being displayed when hidden.. Any help will be greatly appreciated.. Thanks in advance.!
Normal HUD:
Hidden HUD:
hahahahahahaha.. "Close but no cigar..."
– Eduardo Hernandez
Sep 10 '18 at 16:45
1 Answer
1
You can use a RectMask2D component to mask out the letterbox area. You want to attach the RectMask2D to an object that is a parent of your inventory box. Children of the RectMask2D will only appear within the area of their parent, so if the mask does not cover the letterbox area, then your inventory bar will not appear over the letterbox either.
This was exactly what I needed to know.. Thank you very much.!! It worked beautifully.. Cheers mate..
– Eduardo Hernandez
Sep 10 '18 at 16:45
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
"What is this? A bouncy castle for ants?!"
– Parrish Husband
Sep 8 '18 at 0:01