Blocking objects confusion
Home › Forums › Books › Unity 3D UI Essentials › Blocking objects confusion
- This topic has 7 replies, 2 voices, and was last updated 5 years, 2 months ago by
Simon (darkside) Jackson.
-
AuthorPosts
-
February 19, 2015 at 2:36 pm #6640
Paul Hogan
GuestThis is one topic that is stumping me at present with regard to what you need to do to achieve this goal.
I have tried using just the Canvas Graphic Raycaster with Blocking Objects set to 2D then 3D then everything, but the tap which the button receives still gets passed to the 3D objects in my scene.
I have tried using a Physics Raycaster attached to the camera and used a separate script attached to my game object implementing the IPointerClickHandler but still the taps pass through.
February 19, 2015 at 3:24 pm #6641Simon (darkside) Jackson
KeymasterRight first, the answer to your query is a CanvasGroup. it is the only component that will actively block raycasts from passing through it.
You simply add it to the UI control (or grouping GO the UI is attached to) to stop raycasts (all raycasts) passing through the Rect Transform of the GO by selecting the “Block Raycasts” parameter.
The Blocking option only affects other elements within the view of the camera the UI is attached to, similar to Camera layers and depth flags.
Hope this helps.
Simon (Darkside) Jackson
@SimonDarksideJFebruary 19, 2015 at 3:59 pm #6642Paul Hogan
GuestHi, thanks, I tried that, still the taps go through?
Stumped as not sure what the canvas graphic raycaster blocking objects is actually for if you then have to add a control group with a setting to block raycasting too?
Also could it be that it is the way I am intercepting taps in my other script that users the old touch count, creates a raycast and tests for object name to decide a hit?
Should I be removing this and moving to the IPointerClickHandler approach in conjunction with control group?
February 19, 2015 at 4:20 pm #6643Simon (darkside) Jackson
KeymasterI do find a lot of cases that I’m responding to require setting up a new script.
The interfaces are really easy to implement (and extend).
They only provided a basic set of “out of the box” controls, for everything else you have to build your own.
Looking at the source (https://bitbucket.org/Unity-Technologies/ui/src/5fc21bb4ecf4b40ff6630057edaa070252909b2e/UnityEngine.UI/UI/Core/GraphicRaycaster.cs?at=4.6), the Blocking options only affect the UI canvas raycasting. Does not affect the rest of your 3D scene.
The CanvasGroup is supposed to block raycasts, so it is odd that it isn’t. Will investigate further.
Note the UI Extensions post on the forum, I’m managing a bitbucket repository with a host of community built controls to fill in gaps.
Simon (Darkside) Jackson
@SimonDarksideJFebruary 19, 2015 at 6:09 pm #6645Paul Hogan
GuestAh, that is annoying!
I’ve tried the advanced choice on this and still the taps go through?
https://www.youtube.com/watch?v=EVZiv7DLU6E
Will have to scour the Internet to see if I can find an answer…
February 22, 2015 at 8:51 pm #6656Simon (darkside) Jackson
KeymasterThat is certainly one path I had never considered. Attaching UI scripts/events to NON-UI elements.
As you have read, the book is all about using the UI.
All of the guys suggestions seem to be about altering the behaviour of your 3D/2D game and not about managing the UI. (#Shudder EventTrigger)
I agree, certainly worth more investigation.
Simon (Darkside) Jackson
@SimonDarksideJNovember 25, 2015 at 2:36 pm #8849Paul Hogan
GuestBack here again and find it funny (in a way) that I am revisiting the exact same problem on a new app, I never did get it resolved back in Feb. I found this thread by Googling and found it was me that started it lol.
Do you know of any update that addresses this problem, still get taps passing through my buttons to the 3D gameobjects below 🙁
December 22, 2015 at 5:24 pm #8979Simon (darkside) Jackson
KeymasterSorry I missed this. Are you still experiencing issues?
I’ve done testing in this area (especially through the UI Extensions) and not experienced any issues.
Did you solve your problem and what was the fix (if any?)
Simon (Darkside) Jackson
@SimonDarksideJ -
AuthorPosts
- The forum ‘Unity 3D UI Essentials’ is closed to new topics and replies.