Author Topic: Buttons not working in ScrollView  (Read 3384 times)

decept

  • Guest
Buttons not working in ScrollView
« on: January 21, 2013, 01:51:27 PM »
Hello
I've searched around the forum but I couldn't find an answer that helped me. I've done a ScrollView as in example 7 and my items are all image buttons. I added a script with the OnClick function (just writes to the console) to the buttons but it never gets callled. I tried the script on an image button that was outside the ScrollView and there it worked fine.
I do get a click sound when the buttons are pressed though.

The static checkbox is not checked.

Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Buttons not working in ScrollView
« Reply #1 on: January 21, 2013, 03:43:49 PM »
If you get a sound, then the OnClick does work. Make sure your script is attached to the correct object (one with the collider -- same one as the UIButtonSound script is on).

decept

  • Guest
Re: Buttons not working in ScrollView
« Reply #2 on: January 23, 2013, 02:03:34 PM »
Thanks for your reply, allthough I must apology, it was all my fault. I had the same text on all the button and thus could distinguish them. I had only put my OnClick script on two of the buttons and thought they were the first two. But the order was not the same in the ScrollView as in the hierarchy (of course, duh!). It was working all along.

Now though, I noticed another problem. Only some of the buttons work, the rest are not even playing a sound. When trying to find a difference between them I noticed that under the "Box Collider" the Center.Z keeps getting a lower number for each button I add. When changing the Z value to an equally low number as a working button, it works.
So the "Box Collider" is never hit, but seems to be behind something.

I reduced the Transform.Z for the UIGrid object to -2 and that solved it. Is this the correct way to fix this or am I missing something?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Buttons not working in ScrollView
« Reply #3 on: January 23, 2013, 05:15:16 PM »
Switch your scene view's camera to perspective mode and you should be able to see the collision boxes with the UIRoot selected. You should then be able to tell what's blocking your clicks.