ServerClient is a class that contains an integer (clientID), and a string (name), and clients is a list of ServerClient. This is part of a server that will send a list of clients to the newly connected client.
When I run this code with 2 or more clients connected, the string that is generated looks something like this:
ASKNAME;firstclientID|firstclientName
where client ID is the id of the first client, and client name is the name of the first client. Regardless of how many elements are in the list of ServerClients, it will always return the same string, despite the fact that the clients is a populated list. Debug.Log will return the expected strings for each individual iteration, for two clients it looks something like this:
It is when these individual strings are added to askName that the problem occurs, and the code does not function as expected.
I am very confused as to why the string is concatenated once for the first client, but all subsequent clients are ignored despite the populated list. I would greatly appreciate it if someone could help me understand this issue.
I’m not really sure what;s going on here, but for what it’s worth I mocked this up by making clients a List of Vector2’s (since I don’t have your ServerClient class definition) and used the same code that you posted to print their .x and .y values-- it worked fine on my end.
The string isn’t just getting cut off in formatting, I’m assuming. Sorry for being relatively unhelpful.
I did a quick test here (StringTest, C# - rextester) and it seems to work fine. Maybe you have a compilaton error somewhere that’s not being displayed.