playMaker

Author Topic: Rect Transform Is Visible  (Read 2117 times)

Abelius

  • Junior Playmaker
  • **
  • Posts: 68
Rect Transform Is Visible
« on: February 06, 2023, 10:43:27 AM »
I'm in need of determining if a Rect Transform is overlapping and/or completely inside the bounds of an Screen Space Overlay canvas. Or, in other words, if the player can see an UI element though the Main Camera or not.

Googling this threw some scripts, but I'm unable to make use of them with my limited knowledge. Also, most of them focus on giving a solution for Screen Space Camera canvases, not Overlay.

Thanks to the brave soul that tries to make this work.  ::)
Unity 2019.4.9f1
Playmaker 1.9.7f1

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Rect Transform Is Visible
« Reply #1 on: February 06, 2023, 10:46:58 AM »
Hi.
Can you post the links to those scripts

Abelius

  • Junior Playmaker
  • **
  • Posts: 68
Re: Rect Transform Is Visible
« Reply #2 on: February 06, 2023, 12:56:10 PM »
Sure!

This one...:
https://forum.unity.com/threads/test-if-ui-element-is-visible-on-screen.276549/
(2nd post)
...worked for me and has options for fully or partially visible. Only works after setting the canvas to Screen Space: Camera.

This...:
https://forum.unity.com/threads/check-if-2-recttransforms-overlapping.515670/
...just tests overlapping and also needs a Camera canvas.

Then, in this post...:
https://answers.unity.com/questions/918955/is-there-a-simple-way-to-check-if-a-ui-element-is.html
...there's a user (marcojacovone) mentioning he made a modification to the main answer script, so it works for Overlay canvases.

And I think all of them are static methods. I've changed that canvas to Camera at the end, so the first script could work. I hope it doesn't bite me in the back later on.

My only gripe with this is that, for some reason, the Call Static Method action made PlayMaker editor go nuts and barely could fill the parameters before encapsulating the thing in a template and forget about it. I don't know if it's a problem with my PM version, but I can't upgrade atm, I'm afraid.

So, a "normal" action would still be great to avoid editor chaos.
Unity 2019.4.9f1
Playmaker 1.9.7f1