public void LoadGame() { getManager = GameObject.Find("SaveAndLoadManager"); if (getManager != null) { loadManager = getManager.GetComponent("SaveAndLoad") as SaveAndLoad; loadThread = UnityThreadHelper.CreateThread((System.Action)loadManager.LoadGame); } }
public void StartClient(string nickname) { client = new Client(new TcpClient()); client.Nickname = nickname; client.CurrentClient.Connect("192.168.0.87", 6969); stream = client.CurrentClient.GetStream(); LoginData loginData = new LoginData(client.Nickname, ""); SendRequest(client, (byte)RequestTypes.Login, loginData); clientThread = UnityThreadHelper.CreateThread(ClientThread); }
/// <summary> /// Creates new thread which runs the given action. The given action will be wrapped so that any exception will be catched and logged. /// </summary> /// <param name="action">The action which the new thread should run.</param> /// <param name="autoStartThread">True when the thread should start immediately after creation.</param> /// <returns>The instance of the created thread class.</returns> public static UnityThreading.ActionThread CreateThread(System.Action <UnityThreading.ActionThread> action, bool autoStartThread) { Instance.EnsureHelperInstance(); System.Action <UnityThreading.ActionThread> actionWrapper = currentThread => { try { action(currentThread); } catch (System.Exception ex) { //UnityEngine.//Debug.LogError(ex); } }; var thread = new UnityThreading.ActionThread(actionWrapper, autoStartThread); Instance.RegisterThread(thread); return(thread); }
// Use this for initialization void Awake() { // 세이브 & 로드 매니저 오브젝트를 구한다. getManager = GameObject.Find("SaveAndLoadManager"); saveAndLoadManager = getManager.GetComponent("SaveAndLoad") as SaveAndLoad; if (saveAndLoadManager.GetIsLoaded() == false) { initMapThread = UnityThreadHelper.CreateThread((System.Action)InitMapData); } else { loadingMapThread = UnityThreadHelper.CreateThread((System.Action)LoadGameMapData); } //청크배열에 메모리 할당. chunks = new Chunk[Mathf.FloorToInt(worldX / chunkSize), Mathf.FloorToInt(worldY / chunkSize), Mathf.FloorToInt(worldZ / chunkSize)]; }
internal SocketHandler() { mServerTime = 0; mClientBaseTime = 0.0f; mWebSocket = new WebSocket(); mWebSocket.Opened += WebSocket_OnConnected; mWebSocket.Closed += WebSocket_OnDisconnected; mWebSocket.ErrorOccurred += WebSocket_OnErrorOccured; mWebSocket.TextReceived += WebSocket_OnTextReceived; mWebSocket.DataReceived += WebSocket_OnDataReceived; // 初始化 PingPong Thread mPingPongThread = UnityThreadHelper.CreateThread(() => { return; }); mPingPong = new PingPong(); State = ConnectionState.Disconnected; mCmds = new Dictionary <string, Action <string> >(ClientData.Instance.GetCmds()); }
public void StartSearching() { Debug.Log("request to start search for mesh server"); _searching = true; _searchThread = UnityThreadHelper.CreateThread(() => ListenForBroadcasts()); }