Author Topic: UICenterOnChild - Recenter on (optional) child  (Read 6684 times)

AngryGerman

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
UICenterOnChild - Recenter on (optional) child
« 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,

Donkey111

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #1 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #2 on: August 29, 2013, 03:44:32 PM »
Why not just do gameObject.transform.position? CenterOnChild goes to a position, does it not?

AngryGerman

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #3 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 :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #4 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.

AngryGerman

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #5 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

bloomk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #6 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild - Recenter on (optional) child
« Reply #7 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.