Convert a string to something "clickable"

Hey there,

I’ve got a system set up between unity/php/SQL where you can refresh and get a list of players connected to the server, which appear as a string (i.e just text)

I need the player to be able to click on these, and I’m wondering what the right way to do this is? Should I convert this string to an array, and then somehow generate gui.buttons from that array? Or is there a way to convert each line from SQL to a button?

Sorry, here’s my code:

function getUsers(){
		var players=new WWWForm();
		players.AddField("Users",TestInt);
		var w =WWW(getURL,players);
		yield w;
		
				var returnedString=w.data;
				var values=returnedString.Split(""[0]);
				
				var playerButtons =  new Array();
				playerButtons = returnedString.Split();
				
				if(values.length==2){
					upTo=parseInt(values[0]);
					formChat=values[1] + "\n";
					scrollPosition=Vector2(0,Mathf.Infinity);
					
		
				
			
		}
		
	
		yield WaitForSeconds(1);
		refresh();
		
	}

[/code]

Make “values” a script variable (ie, not local to the getUsers function). You will then be able to use it in the OnGUI function to display the list of users (it is already an array of strings). You might find the selection grid control useful here, as it takes a string array and creates a button for each element.

Hey mate,

Thanks for your advice, I actaully got it working using a very similar setup, cheers!