So I am coding a multiplayer game in unity with smartfoxserver, I was trying to build a script that would connect my client to my server but I got the the error:
"The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
This line was displayed over public SmartFox _client;
I attempted to go the the solutions panel and add a reference to System.Runtime
, but I could not find it, the closest I was able to find was System.Runtime.Serialization.
Code is pasted down below, thanks in advance.
using UnityEngine;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using Sfs2X.Entities;
public class Client : MonoBehaviour {
private string host="localhost";
private int port= 9933;
public SmartFox _client;
// Use this for initialization
void Start () {
_client = new SmartFox ();
_client.ThreadSafeMode = true;
_client.AddEventListener (SFSEvent.CONNECTION, OnConnection);
Connect();
}
// Update is called once per frame
void FixedUpdate () {
_client.ProcessEvents ();
}
public void Connect(){
_client.Connect (host, port);
}
public void OnConnection(BaseEvent _event){
if ((bool)_event.Params ["success"]) {
Debug.Log("Successfully connected to server");
} else { Debug.Log("Failed to connect to server")
//failed
}
}
}
尝试在文件顶部添加“ using System”语句。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.