Author Topic: UIDraggablePanel and UITabled moved at runtime  (Read 4982 times)

ijneb11

  • Guest
UIDraggablePanel and UITabled moved at runtime
« on: June 05, 2012, 08:08:11 AM »
Hi,

I recently started using NGUI for some project and I got some behavior I don't understand using UIDraggablePanel.
So when starting my scene I instantiate a prefab with the UIRoot, UICamera and this hierarchy under the camera :

UIRoot
  UICamera
    Anchor (Center)
      UIPanel
         BG Sprite + UIDragPanelContents (with the panel just below as the target)
         UIPanel + UIDraggablePanel (scale 0 1 0)
             UITable (1 column, Down)


I also have a prefab that I want to instantiate several times as a child of the UITable. It is composed like this:

GameObject
   UISlicedSprite + UIDragPanelContents (set the target by code)
   UILabel


If I add several instances of this prefab by hand to the UITable in the editor or when I do it by code with the NGUITools.AddChild(parent, prefab) function, I have 2 problems :
   - first the UITable is moved in such way that its top-right corner is now at the center of the UIDraggablePanel
   - then, when I clicked the only part of 1 element visible in the clipping area, the UIDraggablePanel is moved a lot on the left. The UITable si moved too.


So my question is : what did I do wrong or forget to do ? Why are these 2 widgets moving around ?

Thanks in advance for your help
Benjamin
« Last Edit: June 05, 2012, 08:14:31 AM by ijneb11 »

ijneb11

  • Guest
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #1 on: June 05, 2012, 10:19:33 AM »
So after some investigation, I made a simpler example with the same issue but without any DraggablePanel.
So I juste have a basic NGUI UI with an UITable to which I attach 3 (or more) instances of the last prefab I talked about in my first post. (GameObject - Sprite + Label)

When I click on the UITable's "Reposition Now" or Unity's "Play" button, all the elements under UITable are moved on both screen's axis, aligned one of top of the other, but at the wrong place of the screen.

Does anybody have an idea?
Benjamin

poulpator

  • Guest
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #2 on: June 05, 2012, 10:42:05 AM »
Off the top of my head, I remember having similar problems because I had values for both Scale.x and Scale.y in my parent UIDraggablePanel (where you must put a value only for the axis you want to use). No other ideas for the moment...

ijneb11

  • Guest
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #3 on: June 05, 2012, 11:11:28 AM »
I already had this problem :) This caused the dragging to be done on all the axis not set to 0 indeed. So this part is well set I think.

I tried to replace the UITable by an UIGrid and I don't have this automatic move done. So now I have to get in the details of UITable

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #4 on: June 05, 2012, 01:51:35 PM »
Table has an option where it will keep the contents within the draggable panel. Draggable panel doesn't move, but instead adjusts the clipping rect. Table aligns the clipping rect to itself. The two can conflict if it's not set up correctly, however what the "correct" method is escapes me atm. I've been up for 25 hours so not very helpful at this moment. :P

ijneb11

  • Guest
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #5 on: June 06, 2012, 04:35:15 AM »
Yeah I sa this option and I use it. It works as at the end, the clipping rect is well adjusted over the Table content.
But the Draggable Panel moved ... it x position passes from 1200 to 900 in my case when I click on 1 of the Table children, and that's what's strange.

But you can have some sleep for now, UIGrid saved my day ;)

milali

  • Guest
Re: UIDraggablePanel and UITabled moved at runtime
« Reply #6 on: February 25, 2013, 05:48:14 AM »
I will try UIGRID also I am having HUGE dramas with uitable and dragable panels moving.