Author Topic: Button doesn't work if I change the layer  (Read 3470 times)

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Button doesn't work if I change the layer
« on: January 17, 2013, 12:46:43 PM »
Well, the title says the problem, when it's on default it works perfectly, I changed it to GUI layer (created by me), and doesn't work at all, not even the mouse over.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #1 on: January 17, 2013, 09:05:43 PM »
You can't change the layer of a single widget within a UI hierarchy. You need to change the entire UI to use the GUI layer.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #2 on: January 17, 2013, 10:46:40 PM »
Yeah, I changed everything, from the UIRoot and below, and doesn't work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #3 on: January 17, 2013, 10:48:48 PM »
Is your UICamera set to use that layer? Check its event mask.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #4 on: January 18, 2013, 07:13:01 AM »
Yes, it is.
Another option?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #5 on: January 19, 2013, 01:51:28 AM »
The only other thing is to make sure that the "Raycast Hit Triggers" option is checked, but I don't see why it would work with one layer and not with another, assuming you checked everything else correctly. As I said the #1 reason is that the event mask on the UICamera is not set correctly. Other than that, there isn't much I can say because those are the only reasons why this wouldnt work.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #6 on: January 21, 2013, 10:23:11 AM »
The "Raycast Hit Triggers" is enable and the culling mask is on the layer that I created for GUI, so I don't know what it is.

At least it works with a diff layer but I've to add that layer to the camera mask.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #7 on: January 21, 2013, 05:28:11 PM »
If you make a new GUI layer, make sure that
1) the 2d Camera is drawing that layer: "culling mask"
2) the UICamera component is set to send messages to that layer: "Event receiver mask"
3) that your whole hierarchy actually uses that layer.
4) PhysicsManager should have "Raycasts Hit Triggers"

Then it should work fine.





jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #8 on: January 22, 2013, 07:09:37 AM »
Quote
If you make a new GUI layer, make sure that
1) the 2d Camera is drawing that layer: "culling mask"
2) the UICamera component is set to send messages to that layer: "Event receiver mask"
3) that your whole hierarchy actually uses that layer.
4) PhysicsManager should have "Raycasts Hit Triggers"

Then it should work fine.

I was missing the second point!

thanks a lot Nicki!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #9 on: January 22, 2013, 08:44:22 AM »
Is your UICamera set to use that layer? Check its event mask.
Yes, it is.
Another option?
As I said the #1 reason is that the event mask on the UICamera is not set correctly.
*sigh*
« Last Edit: January 22, 2013, 08:45:53 AM by ArenMook »

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Button doesn't work if I change the layer
« Reply #10 on: January 22, 2013, 08:58:04 AM »
Sorry!!! I tought you was talking about "culling mask". I know it's my fault, but this is really new for me and I'm fighting everyday at work with Unity.