Author Topic: UIDragPanel  (Read 12903 times)

Alex

  • Guest
UIDragPanel
« on: April 13, 2012, 01:04:24 PM »
Hi,
I would like to know if there is some document that explain in detail how to use UIDragPanel.
i used to use UIDragObject but you mentioned here http://www.tasharen.com/forum/index.php?topic=4.msg6#msg6  that is goin to be obsolate.
please note that all my UIDragObject replaced by UIDragPanel but something is not working.
I know there is example but examples are really time killer because i need to switch back and forth between my scene and to discover what i need to apply in order to make it work.

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragPanel
« Reply #1 on: April 13, 2012, 03:27:18 PM »
1. Attach UIDraggablePanel to the panel you wish to be able to drag, and set up its properties (mainly Scale: (1,0,0) to drag only horizontally, (0,1,0) to drag vertically).
2. Attach UIDragPanelContents to the collider you wish to perform the drag, and have it point at the UIDraggablePanel.

Alex

  • Guest
Re: UIDragPanel
« Reply #2 on: April 13, 2012, 03:36:51 PM »
Hi,
This is what i'm doing:

Anchor->Panel->Panrl[with UIDragable Panel and clipping set] ->UIGrid[with Cell width and cell height set to the item dimenssion] -> [ Items with UIDragPanelContent ]

the first problem is that soon as i click play,all my items shift a bit left and up
then the second problem is that the clipping not working anymore, it show everything on the screen.
how to fix that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragPanel
« Reply #3 on: April 13, 2012, 03:51:39 PM »
Clipping only works for items inside the clipped panel, and only if those widgets are using "Unlit/Transparent Colored" shader in their material (for the atlas). Also, shaders must be on. This means if you have current target set to iOS/Android, make sure that you're using GLES 2.0, not GLES 1.1, which doesn't support shaders. Finally, make sure that the quality is set to something that supports shaders (ie: not "fastest").

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIDragPanel
« Reply #4 on: April 13, 2012, 03:53:33 PM »
Do like this

* root
** anchor
*** dummy game object (so you have a common parent)
****ScrollCollider
**** ScrollView (UIPanel, UIdraggablepanel, clipping on the panel etc)
*****UIGrid gameObject
******Individual objects in your grid with UIDragPanel

Remember to set the draggablePanel in the individual objects to the ScrollView object when you populate the list in your code.

I had some battles with the prefab having an offset in it, and then my UITable (that I use instead of grid) and the dsraggable panel fought over how they should be repositions, so they were halfway outside the view (and half-clipped).

Also remember to set the right settings on the UIDraggablePanel like the directions you can drag etc.

Edit: I forgot to explain the ScrollCollider. That's a gameobject with a UIDragPanel and a collider that covers the entire clipped area. You have to set the colliders depth to be lower than the individual objects. This makes you able to click on "empty space" in your view and drag it. otherwise you have to drag on the individual objects. Also note that the scroll collider and scrollview are on the same level, not child-parent. (essentially the collider could be anywhere, but this way makes a little sense.)
« Last Edit: April 13, 2012, 03:58:15 PM by Nicki »

Derell Nar

  • Guest
Re: UIDragPanel
« Reply #5 on: April 27, 2012, 05:37:11 AM »
Hi.

I've setup a Scroll Panel that works fine if all the items are already in the Hierarchy.
However if I try to add items dynamically via code to the scroll view (as a child of UIGrid) it doesn't work anymore.

Everytime I add a new item from code, it doesn't show in the Game View, I can see it in the Scene View and as I add more they pile up one on top of each other...

Does anyone know how to correctly add items dynamically to the scroll list ?
« Last Edit: April 27, 2012, 05:46:48 AM by Derell Nar »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragPanel
« Reply #6 on: April 27, 2012, 05:50:33 AM »
UIGrid.repositionNow = true.