Showing scrollbars inside of a GUI Window

I’m working on a menu where the player can choose what song to play from a jukebox, but I’ve run into a dilemma on getting the scroll bars to show inside a window I’ve made for the list. Here’s the part of my code I’m having trouble with:

void OnGUI() {

        jukeboxWindow = new Rect(10, 10, jukeboxWidth, jukeboxHeight);
        GUI.Window(0, jukeboxWindow, DrawJukeboxMenu, "Jukebox");

    }


    void DrawJukeboxMenu(int windowID) { 

        position = new Rect(10, 10, posWidth, posHeight);
        viewpoint = new Rect(0, 0, 520, 200);

        scrollPos = GUI.BeginScrollView(position, scrollPos, viewpoint);

        for (int i = 0; i < playlistSongs.Length; i++) {
            GUILayout.Label(playlistSongs[i]);
        }
        GUI.EndScrollView();
    }

At this current state, the scroll bars do not appear, as they are in a window. If I were to start the scroll view before the window, it shows outside of the window, which is not what I want. I’ve been thinking of using a GUI Group to encase the list inside there and place it in the Window, but I think it would have the same effect.

Ultimately, however, I hope for the list to look similar to this, as I’m trying to include controller support for my game:

I also wanted to know if the selections on the menu above were the equivalent of Labels or Buttons in Unity. In other words, do you think it would be better to use buttons with a custom style or labels with OnMouseOver() controls in the list when selecting the list items?

I think the problem here:

viewpoint = new Rect(0, 0, 520, 200);

you can try:

viewpoint = new Rect(0, 0, 520, playlistSongs.Length * itemHeight);

For display selected item, you can use GUILayout.Toggle with appropriate custom style.

Unfortunately, your suggestion didn’t work out. I’ll try working on it elsewhere. If I follow a tutorial for creating an inventory system, I may find my solution for it there. The jukebox system is not essential, though, so I can work on it later. As for the selections, I’ll try out using the toggle buttons as you suggested.

Thanks again.

Hey, I am not seeing my scroll bar either. Here is my long script:

#pragma strict
//Private Variables
private var InventoryOn = false;
private var scrollBarChopGrid : Vector2 = Vector2.zero;
private var GridValue : float = -1;
var myskin : GUISkin;

//GUI Pos/Size
var NamePosition : Vector2 = new Vector2(30,30);
var NameSize : Vector2 = new Vector2(250,250);
var GridPosition : Vector2 = new Vector2(10,5);
var GridSize : Vector2 = new Vector2(323,410);
var ClosePosition : Vector2 = new Vector2(312,5);
var CloseSize : Vector2 = new Vector2(35,35);
var ScrollPosition : Vector2 = new Vector2(312,5);
var ScrollSize : Vector2 = new Vector2(355,500);
var WindowPosition : Vector2 = new Vector2(0,0);
var WindowSize : Vector2 = new Vector2(360,360);
var DragWindowPosition : Rect = Rect(0,0,WindowSize.x,WindowSize.y);

//Textures
var InventoryWindow : Texture;
var CloseIcon : Texture;
var Grids : GUIContent[];

function Update () 
{
   var AddingNewItem : InventoryAddItem = GetComponent(InventoryAddItem);
   //On or Off
   if (Input.GetKeyUp ("i"))
   {
   
      if (InventoryOn == false)
      {
         InventoryOn = true;
      }
      else if (InventoryOn == true)
      {
         InventoryOn = false;
         scrollBarChopGrid.y = 0;
      }
   }
   //Window Drag Fix
   if (Input.GetKey("left shift"))
   {
      if (Input.GetKeyDown("i"))
      {
         DragWindowPosition.x = 0;
         DragWindowPosition.y = 0;
         
      }
   }
   AddingNewItem.newItem();
}

function OnGUI()
{
   GUI.skin = myskin;
   if (InventoryOn == true)
   {
      DragWindowPosition = GUI.Window(0, DragWindowPosition, DoMyWindow, "");
   }
}

function DoMyWindow(windowID : int)
{
   if (InventoryOn == true)
   {
      GUI.BeginGroup(new Rect(WindowPosition.x, WindowPosition.y, WindowSize.x, WindowSize.y), InventoryWindow);
         //Name
         GUI.Label(Rect(NamePosition.x, NamePosition.y, NameSize.x, NameSize.y), "Your Inventory");
      
         //Close Button
         if (GUI.Button(Rect(ClosePosition.x, ClosePosition.y, CloseSize.x, CloseSize.y), CloseIcon))
         {
            InventoryOn = false;
         }
         //Scroll Bar
		scrollBarChopGrid = GUI.BeginScrollView(Rect (ScrollPosition.x, ScrollPosition.y, ScrollSize.x, ScrollSize.y), scrollBarChopGrid, Rect(0,0,0,420));
			// Grid
			GridValue = GUI.SelectionGrid(Rect(GridPosition.x, GridPosition.y, GridSize.x, GridSize.y), GridValue, Grids, 5);
         GUI.EndScrollView();
         
         //Dragable Window
         GUI.DragWindow (Rect (WindowPosition.x, WindowPosition.y, 10000, 40));
      GUI.EndGroup();
         
   }
}

I dunno why my scroll bar isn’t showing up, does anyone know while???