[英]Unable to reference system.runtime unity
因此,我正在與smartfoxserver一起編寫多人游戲,我試圖構建一個將客戶端連接到服務器的腳本,但出現錯誤:
"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'.
該行顯示在public SmartFox _client;
我嘗試轉到解決方案面板並添加對System.Runtime
的引用,但找不到它,我能找到的最接近的是System.Runtime.Serialization。
代碼預先粘貼在下面,謝謝。
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”語句。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.