Author Topic: Making scroll view selector menu  (Read 4792 times)

Progeny

  • Guest
Making scroll view selector menu
« on: September 22, 2012, 08:36:11 AM »
Hi everyone! I'm new to Unity development and NGUI package. I know NGUI is going to save my life!

I'm trying to implement this: http://www.tasharen.com/ngui/ex7.html for making a level selector.
I can manage button's click to start a new scene, simply trigger OnClick()

What I want is having on start the first item centered (highlighted). When I startup the scene it behave like that: http://img109.imageshack.us/img109/7752/schermata20120922alle15.png

But i don't know to what object attach a script and how to shift the first item to the correct position to be centered and highlighted.

Could you help me? Thanks

Progeny

  • Guest
Re: Making scroll view selector menu
« Reply #1 on: September 22, 2012, 09:06:26 AM »
I'm now able to recent on startup by doing this in the UICenterOnChild
but how can I access to a specified index panel? suppose I want the last level (we suppose number 5) to be centered, how can I access to the 5th panel?

  1.         void Update()
  2.         {
  3.                 Recenter();
  4.         }

Progeny

  • Guest
Re: Making scroll view selector menu [SOLVED]
« Reply #2 on: September 22, 2012, 09:11:53 AM »
 :-[ :-[
solved

GetChild(i);

i is the index of the centered panel

  1.                 // Determine the closest child
  2.                 for (int i = 0, imax = trans.childCount; i < imax; ++i)
  3.                 {
  4.                         Transform t = trans.GetChild(i);
  5.                         float sqrDist = Vector3.SqrMagnitude(t.position - offsetCenter);
  6.  
  7.                         if (sqrDist < min)
  8.                         {
  9.                                 min = sqrDist;
  10.                                 closest = t;
  11.                         }
  12.                 }