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:
how the HUD looks normally



Hidden HUD:
how the HUD looks when hidden





"What is this? A bouncy castle for ants?!"
– Parrish Husband
Sep 8 '18 at 0:01





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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế