Easy way to center GUI Textures on a path?

Hey guys! I am making a menu that will have a vertical bar, that will be smaller at the top and wider at the bottom, on the right and I want my GUI Textures to slide along it. BUT. I can make them slide, but I ran into a problem of how to center them at the path. Lets say I have 5 buttons, the middle will be centered and the 2 on the bottom and 2 on the top will just be above it. But what about 4 elements?

You can calculate the vertical starting point like this:

  • calculate the height of n buttons (number of buttons x button height)
  • subtract height of all buttons from height of vertical bar
  • divide this number by 2

Take the result and start your first button that many pixels from the top.

var sliderRectangle  :  Rect;
var buttonRect       :  Rect;
var buttonHeight     :  int;
var buttonCount      :  int;

function OnGUI ()
{
    var totalButtonHeight : int = buttonCount * buttonHeight;

    var startY = sliderRectangle.y;

    startY += ( sliderRectangle.height - totalButtonHeight ) / 2;

    for ( var i = 0; i < buttonCount; i ++ ) {

        buttonRect.y = startY + ( i * buttonHeight );

        if ( GUI.Button(buttonRect, "I am button " + i) ) {
          print("button " + i + " has been pressed);
        }    
    }
}

Not sure if this will work with your non-rectangle slider...