Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AngryGerman on August 26, 2013, 05:42:30 PM

Title: UICenterOnChild - Recenter on (optional) child
Post by: AngryGerman on August 26, 2013, 05:42:30 PM
Aren,

you were so kind to agree to include a change request by me a couple days ago - http://www.tasharen.com/forum/index.php?topic=5473.msg26012#msg26012

Could I make another request/suggestion?

In our project I need to move a draggable panel to a given GO in a dynamic created list of entries by giving the CenterOnChild script a specific GameObject. Using your UICenterOnChild script I achieved this by adjusting the script to accept an optional parameter. If it's not too much to ask, could that be included in a future release ?

thanks,
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: Donkey111 on August 29, 2013, 01:35:18 PM
Aren,

you were so kind to agree to include a change request by me a couple days ago - http://www.tasharen.com/forum/index.php?topic=5473.msg26012#msg26012

Could I make another request/suggestion?

In our project I need to move a draggable panel to a given GO in a dynamic created list of entries by giving the CenterOnChild script a specific GameObject. Using your UICenterOnChild script I achieved this by adjusting the script to accept an optional parameter. If it's not too much to ask, could that be included in a future release ?

thanks,

So what exactly would the method for executing this script be AngryGerman?

1. Attach the script to the container of your options (draggable contents). I will call my container "TestContainer"
2. CAll TestContainer.Recenter(ObjectToCenterOn);

Is that it? I'm trying to do something similar and would love your help.
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: ArenMook on August 29, 2013, 03:44:32 PM
Why not just do gameObject.transform.position? CenterOnChild goes to a position, does it not?
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: AngryGerman on August 29, 2013, 04:22:51 PM
So what exactly would the method for executing this script be AngryGerman?

1. Attach the script to the container of your options (draggable contents). I will call my container "TestContainer"
2. CAll TestContainer.Recenter(ObjectToCenterOn);

Is that it? I'm trying to do something similar and would love your help.

@Donkey:

1.)
CenterOnChild is on the same GO in the Hierarchy as the UIGrid which is a child of the GO that contains the DraggablePanel, so:

DraggablePanel
|
-> UIGrid
    UICenterOnChild

2.)
call Recenter(yourGO) with a reference to UICenterOnChild

e.g.: centerOnChild.Recenter(yourGO);   (or adjusted to Aren's suggestion)

Why not just do gameObject.transform.position? CenterOnChild goes to a position, does it not?

@Aren: you mean passing in a GO's position, rather than a GO as a whole if I understand you correctly? Would work too, but then I have to type (go.transform.position) for every call to Recenter(). I can save myself that by passing the whole GO and dig down into the position inside the function :)
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: ArenMook on August 29, 2013, 04:25:56 PM
Yes but it would still have to go by position inside, so saving a few extra characters isn't worth adding an extra function for.
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: AngryGerman on August 30, 2013, 02:24:48 PM
my proposal added an optional parameter to the existing function. Wasn't asking for an additional one. Unless I'm missing something in our conversation
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: bloomk on September 17, 2013, 08:12:23 PM
what's the status of this? I would like to be able to pass an item to center on as well.
Title: Re: UICenterOnChild - Recenter on (optional) child
Post by: ArenMook on September 18, 2013, 01:58:16 PM
Add a helper function for it if you need it. I don't see the benefit of adding an extra function just to save having to type .transform.position. I prefer to keep it clean with a single function.