playMaker

Author Topic: How To Stop Raycast / Button Click , Going through UI Panel[SOLVED]  (Read 25813 times)

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
I am stuck in a place and cant figure out the solution .
Would be very obliged if , get some help for it .

The problem is :

I have a UI Score Panel With Button in it, and Behind the UI Panel I have a Game object (Ex: Cube ) which have Mouse Pick option attached to it.
So the scenario is , When Cube is Clicked, An UI Text appears.

But my problem is , when i have the UI Score Panel Open which covers the entire screen, and on mouse click on Button on the UI Score Panel., , The CUBE which is behind the UI  Score Panel  also gets activated or triggered.

So how do i stop it .
Please suggest me a solution , would be very obliged and thankful.

Regards,
Shihan
« Last Edit: August 22, 2019, 02:18:04 AM by jeanfabre »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #1 on: August 18, 2019, 02:52:38 PM »
There's the option block raycasts that should make sure a ray is blocked by the object. It's present in many UI elements.
If it's a panel, it should block every ray that is cast from the caster (mouse or touch input at coordinates x y).
Right on the canvas you have an option to block certain objects; you can use layers. I can't try your scene but maybe the UI layer is not working in the same camera space? There are 'masks' to use too. Or perhaps the part that detects mouse inputs works in its own area and does ignore the UI altogether?
Another suggestion is, are you using the event trigger component?

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #2 on: August 18, 2019, 04:03:40 PM »
Dear Sir, Thank you for the reply.

Sir, Could you please guide me to BLOCK Raycast option , which maybe i am missing. Because on my Panel I have not seen that option

Also, In regard to Layer , i have tried that option and i dont know why , mouse pick Doesnt pick the layer , which i have assigned it to .

Ex: My Game Obj (Cube ) is in  ie: Game Layer
So When Cube is clicked, The UI Panel Which also is in Game layer should pop up.
But it doesnt do that.

And Also my 2nd Game object Ex:(Cylinder) Which is behind the Panel when Panel Pop Up, ....Which also have same features as mouse pick, Option , and when Mouse Clicked, IT pop up NEW CYLINDER PANEL.

So , i really dont know how can i stop the Penetration of Ray / or Mouse Pick Going through the initial or main panel of CUBE PANEL Button .

I have not used masks before so really dont know the functionality of IT.
And My Canvas is in Screen Overlay Mode

Any more suggestion will be very helpful for me .

Regards,
Shihan
 

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #3 on: August 18, 2019, 05:52:29 PM »
Screen overlay mode should work fine for 99% of UI implementations.
I see that you put your scene objects and UI elements in the same layer. But there's a default UI layer which you may want to use instead for your UI elements.

Unity is so tricky sometimes. The ray blocking is obviously based on spatial information, i.e. which obstacle is hit first and what to do next.
Layer ordering is important, and even placement on the Z axis could make a difference.

The Block raycast option is seen for example in Graphics Raycaster component on your Canvas, which usually is the last component on this type of game objects. It's also available in UI Image and UI Button.

You will find plenty of useful information here:
https://www.google.com/search?q=unity+UI+element+doesn%27t+block+ray+cast

I hope this will help you.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #4 on: August 19, 2019, 02:15:41 AM »
Hi,

 I make extensive use of CanvasGroup component, which features not only raycast control, but alpha and interactable, very handy for panel control.

Bye,

 Jean

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #5 on: August 19, 2019, 10:39:50 AM »
Dear Sir,
Broken Stylus Thank you for the reply,

I have tried Graphics Raycaster, and tried to ignore the Raycast by putting the Graphics Raycaster on the panel and tried to ignore mask the Layer which the Game obj Cube is on , but dint work dont know why maybe i am doing something wrong.

 

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #6 on: August 19, 2019, 10:41:47 AM »
Dear Sir Jean ,

Thank you for the reply,

Sir, in regard to canvas group component , how can i access your work , or is there a tutorial for it. I am not understanding .

Thanks,

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #7 on: August 19, 2019, 12:56:20 PM »
Dear Sir Jean ,

Thank you for the reply,

Sir, in regard to canvas group component , how can i access your work , or is there a tutorial for it. I am not understanding .

Thanks,

Like all components, you can add it to your Game Object by clicking on Add Component in the Inspector tab. In the search field, type "canvas group" and you'll find the component.
I don't think it will solve your problem at all though.
Have you watched the videos and read the links I provided in my former post? Some of it should give you a solution since you're not the only one who seems to have had an issue with properly blocking rays.

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #8 on: August 19, 2019, 06:32:16 PM »
Dear Broken Stylus Sir,

Thank you for the message , i have gone through the recommendation you had given but mostly i have seen people use code to prevent the Raycast action.

And i really have Zero knowledge of coding .

But for my problem which i was facing i solved it using the method of Bool.

When Panel Active Bool = True,
And When Bool = True , Mouse pick is deactivated.

So this solved my issue , but still would have loved to learn about the Blocking of Raycast with playmaker action .

Still Thank you sir for your concern and messages.

Regards,
Shihan

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #9 on: August 21, 2019, 02:13:57 AM »
Hi

Once you have your CanvasGroup Component on your GameObject, you can control it using the actions:

UiCanvasGroupSetProperties
UiCanvasGroupSetAlpha


we also have a proxy component called PlayMakerCanvasRaycastFilterProxy

That you control via the action UiCanvasEnableRaycast

this one is closer to what you see in c# coding.

 Bye,

 Jean


apageeltd

  • Playmaker Newbie
  • *
  • Posts: 38
Re: How To Stop Raycast / Button Click , Going through UI Panel
« Reply #10 on: August 21, 2019, 11:07:38 AM »
Dear Jean ,

Sir, Thank you for the help .

I will definitely work on the option as per your suggestion

Regards,
Shihan