Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AndreasRk on July 01, 2013, 08:19:58 AM

Title: UIDraggablePanel ResetPosition() Problem
Post by: AndreasRk on July 01, 2013, 08:19:58 AM
Hi,

I got a problem with my draggable panel.

The first time it is filled and scrolled it is completely fine. When I then remove all objects and fill it with other objects (Its an Inventory, Horizontal drag, with local start coordinates of 475.0f), the start coordinates are bonkers as expected, so I use mUIDraggablePanel.ResetPosition(). This throws my DraggablePane as well as the Clipping pane on the border of known space at something like 33,000 as x coordinate.

There might be reasons as local coordinates and world coordinates or some other reason.
I might also consider to find out, what the first Item is, but that does not seem right.
There is a resetPosition function, I just dont use it right.

I hope you understand what happens and can help.
If there are questions, please ask.
Title: Re: UIDraggablePanel ResetPosition() Problem
Post by: ArenMook on July 01, 2013, 11:40:54 PM
How are you adding your objects? You need to use NGUITools.AddChild to add them directly to a parent object. Using Instantiate will not parent the object for you, so you would have to reset the position yourself after you do that.
Title: Re: UIDraggablePanel ResetPosition() Problem
Post by: AndreasRk on July 02, 2013, 03:29:17 AM
You are right I instantiate with
  1. InvShowcase lInvShowcase = Instantiate(mPShowcase, lPos,Quaternion.identity) as InvShowcase;
and then set its transform parent to the Transform of the GridPane.

Allright, works well.
Actually the reset part works great. But I would want to focus on the first Item, so it needs to be placed slightly off.(Will maybe imitate a slight auto-swipe or something, will be great.)

And I had a problem with the sorting from the grid pane, if sorting is active, (I copied the original and changed the comparer) and I show all - then only one group and then all again, there is a gap before the one from the group is placed.
As if it was there twice and got removed after the update.
I tried if that is because of the regular Destroy and if there is a NGUITools.Destroy and was not disappointed, now it works.

So you made me happy in two ways. I wish you the two happiest days you can imagine, good sir :-)


edit:
One thing that is really funny... I had a comment in the code - my comment:
// Some kind of Addchildren (I guess NGUI.Tools.AddChildren)
So ... before I decided to use the normal version, I was considering using a NGUI Version as it seems :-D
Title: Re: UIDraggablePanel ResetPosition() Problem
Post by: ArenMook on July 02, 2013, 11:08:01 AM
:)

Weird coincidence... I opened this topic to read the reply and was interrupted by a knock on the door. Walked downstairs -- first part of my car arrived! That made me really happy. Then I got back to my computer and read your post wishing me two happiest days. Hmm... o_O I guess the second one will be when I get the actual car, eh? :)