I met this and feel so confused, ANY help?
I found i can not get int:-1 from WCF in Unity
So made a simple test to show what happened.
And I have to say this is totally crazy… please help
Host Code:
public void testFunction(ref int num) {
num = -1;
}
public int testFunction2() {
return -1;
}
And test it… NICE
Client Code in Unity:
public class staticTest : MonoBehaviour {
void Start () {
int num3=10;
int num4=10;
//connect to WCF
EndpointAddress endpoint = new EndpointAddress("net.tcp://192.168.1.250:8910/UserService");
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
UserServiceClient client=new UserServiceClient(binding,endpoint);
//GO!
client.testFunction(ref stat.num1);
Debug.Log("Ref Static signed int in mono returns :"+stat.num1);
client.testFunction(ref stat.num2);
Debug.Log("Ref Static UNsigned int in mono returns :"+stat.num2);
client.testFunction(ref num3);
Debug.Log("Ref Local int in mono returns :"+num3);
client.testFunction2();
Debug.Log("Can mono just accept a -1 from wcf?:"+stat.num1);
Amethod(ref num4);
Debug.Log("Local method ref is fine:"+num4);
}
void Amethod(ref int num){
num=-1;
}
}
public static class stat{
public static int num1=1;
public static int num2;
}
Very easy,just repeat some simple call.
But result is upset