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?