2D Toolkit Forum

2D Toolkit => Support => Topic started by: kurayami88 on January 22, 2014, 05:29:17 pm

Title: UI raycast zone
Post by: kurayami88 on January 22, 2014, 05:29:17 pm
Hi,

I have setup a camera zone of near -100 far 100...
and have a button in the scene..

However, it seems i am unable to click (interact) with the button if the button's Z-order ( entire object, even if it's the button is a child of another parent object) is in the positive side... z > 0 ...

to further elaborate, the collider of the button is the one outside the world coordinate z > 0 .
if the collider intersects into world coordinate z <= 0 , then it can interact...

i.e., collider size = 10, but falls into z > 0 and no cross over into z <=0 ; e.g. z = 6 thus collider area is from z ( 1 to 11) which is not intersecting z <= 0 ... CANNOT CLICK...

i.e. no2, collider size = 10, and cross over into z <=0 ; e.g. z = 5 thus collider area is from z ( 0 to 10) which is intersecting z = 0 ... thus can click...

i.e. no3, collider size = 0.01, and cross over into z <=0 ; e.g. z = -5 thus collider area is from z ( -4.995 to -5.005) which is within z <= 0 ... thus can click...

extra details, collider z <= 0, but within camera zone ( defined earlier as -100) ; can click....but outside camera zone, e.g. z < -100 then it cannot be clicked...

----------

why is this?
shouldn't the raycast zone follow the camera setting which is from -100 to 100? AKA from A <--> B (and not A to 0)
Title: Re: UI raycast zone
Post by: unikronsoftware on January 22, 2014, 09:35:21 pm
What camera are you using, and what i the position of the camera vs button? Is there a hierarchy?
Title: Re: UI raycast zone
Post by: kurayami88 on January 28, 2014, 11:46:38 am
Sorry for taking so long to respond... there was no email-notification :P

---------------

Quote
What camera are you using,
the provided tk2dcamera setup in the "create" section of the hierarchy panel.

Quote
and what i the position of the camera vs button? Is there a hierarchy?
\
 I 'child' all other game objects under it.. main parent object @ world location (0,0,0) ... *hmm.. perhaps this is the reason? shouldn't be...*
though the setup of the camera "clipping planes" is from -100 to 100...
Title: Re: UI raycast zone
Post by: unikronsoftware on January 29, 2014, 12:08:12 pm
Hmm. This is quite bizarre. Either that or I've misinterpreted what you're doing. Could you email a repro case to support at unikronsoftware.com, please?
Title: Re: UI raycast zone
Post by: kurayami88 on January 29, 2014, 01:18:04 pm
i'll just post a simple test scene here... (easier to track same topic rather than you having to search through support channel)
tell me if you require an email otherwise...

------------
http://goo.gl/XBC08H (requires original 2dToolkit package to run... duhh...)

contains a test scene with 3 buttons... two are clickable and 1 is not (as illustrated in my explanation in the first post)
Title: Re: UI raycast zone
Post by: unikronsoftware on January 30, 2014, 12:18:34 pm
There is a bug in tk2dUIManager when the near clip plane is negative. Please change the following code to fix it.
tk2dUIManager.cs, line 657
from
Code: [Select]
            if (Physics.Raycast( ray, out hit, currCamera.HostCamera.farClipPlane, currCamera.FilteredMask )) {to
Code: [Select]
            if (Physics.Raycast( ray, out hit, currCamera.HostCamera.farClipPlane - currCamera.HostCamera.nearClipPlane, currCamera.FilteredMask )) {
Title: Re: UI raycast zone
Post by: kurayami88 on January 30, 2014, 02:21:22 pm
There is a bug in tk2dUIManager when the near clip plane is negative. Please change the following code to fix it.
tk2dUIManager.cs, line 657
from
Code: [Select]
            if (Physics.Raycast( ray, out hit, currCamera.HostCamera.farClipPlane, currCamera.FilteredMask )) {to
Code: [Select]
            if (Physics.Raycast( ray, out hit, currCamera.HostCamera.farClipPlane - currCamera.HostCamera.nearClipPlane, currCamera.FilteredMask )) {

yey... that worked.. thx  :)
wonders why nobody reported this earlier :P... was bugging me for quite a while.
Title: Re: UI raycast zone
Post by: unikronsoftware on January 30, 2014, 02:26:42 pm
I think no ones actually tested it with a negative near clip plane, it will work fine (or at least appear to do so) with a positive one.