Author Topic: Strange UIDragPanel issue with dynamic buttons  (Read 2302 times)


  • Guest
Strange UIDragPanel issue with dynamic buttons
« on: May 21, 2012, 12:19:38 PM »

I am having some strange issues with UIDragPanels. This is what I am doing:

  • I have a horizontal grid of buttons that go across the screen.
  • The buttons are added to the grid at runtime.
  • The buttons are prefabs, that are setup using textures pulled form asset bundles like so:
      btnTex = NGUITools.AddWidget<UITexture>(transform.gameObject);
      btnTex.material = new Material(Shader.Find("Unlit/Transparent Colored"));
      btnTex.material.mainTexture = texOff;
      GetComponentInChildren<UILabel>().text = name;

  • I have a temp loading button which is also a prefab but uses sprites from an atlas.
  • Once the buttons are loaded the temp button is removed
  • The buttons all get added to the grid ok, and I can scroll them.

Things get weird when I try and interact with them. I can only ever click on the buttons that are visible in the left hand part of the list.
For example, the following buttons are shown:
I can only click on A and B.
If I scroll the list so
CDEF are showing, then I can only click on C and D.

While in play mode if I drop my load button onto the list, suddenly I can click on any of the buttons, but I can't see what is being done differently between this and what I am doing programatically.

Any suggestions?

I have tried calling the following, before and after adding and removing the buttons.
dragPanel.repositionClipping = true;

Finally, this was working on an older version of NGUI, before the new UIDragpanel was added (pre scroll bars).



  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Strange UIDragPanel issue with dynamic buttons
« Reply #1 on: May 21, 2012, 12:22:42 PM »
Sound like the drag area that you assigned to the drag panel is moving with the dragging. You need to have the drag BG (the area behind the buttons if none exist) outside of the drag panel's children. Do your buttons have UIDragPanelContent components attached? Are the button's colliders setup properly and in the correct Z space.


  • Guest
Re: Strange UIDragPanel issue with dynamic buttons
« Reply #2 on: May 21, 2012, 01:13:14 PM »
Bingo. My background image that has the dragpanelcontents had its collider closer to the camera than the buttons.