Hey everyone,
I have a connection to a MS SQL database. The Query sends a simple “Select Column1 From MyTable”
Ive been able to populate using a label, the results
However, I cant seem to figure out how to tell it to create a GUI.Button for each row that gets reported back.
The Gui button would obviously fire another SQL Query once selected, but that i can handle.
Any advice would be really helpful
//create list of buttons
void LessonWindowList ( int windowID ) {
scrollPosition = GUILayout.BeginScrollView( scrollPosition );
if( _GameItems != null ) {
if( _GameItems.Count > 0 ) {
foreach( data itm in _GameItems ) {
if ( GUILayout.Button("Button Label Name) ) {
//WHATS HAPPEN IF USER CLICKED THE BUTTON
}
}
}
}
}
GUILayout.EndScrollView();
}
_GameItems contains the list of your data from database.
You can also use for loop to create the buttons
void LessonWindowList( int windowID ) {
scrollPosition = GUILayout.BeginScrollView( scrollPosition );
for( int x = 0; x <= yourLimit; x++ ) {
if( GUILayout.Button( "no: " + x ) ){
}
}
GUILayout.EndScrollView();