Greetings,
I’m trying to send a simple struct from client to host using a command but it doesn’t work. I have no problem sending strings or ints.
The whole code is very simple.
Here’s my struct:
struct Names
{
int x {get;set;}
string[] names{get;set;}
public int GetX() {return x;}
public string[] GetNames() {return names;}
//probably irrelevant concerning my problem but I'll put it anyways
public void setNames(List<string> NamesToSet)
{
x = NamesToSet.Count();
names = NamesToSet.ToArray();
}
}
Then I call this method from a button :
public void SendNames()
{
Names names = new Names();
//Some code
CmdSendNames(names);
}
Which calls this method :
void CmdSendNames(Names names)
{
Debug.Log(names.GetX().ToString());
}
But nothing happens on the server side. Again, if I send directly a string it works fine. For instance, if instead of putting in parameters (Names names) I use (string[ ] names) it works (of course I also change the parameters sent when calling this function).
Also I have a warning : “The class / struct Names has no public or non-static fields to serialize”.
I don’t know what it means.
Any help would be very appreciated.