// Use this for initialization void Awake() { // gm.InitPlayer(100, 100, ""); // gm.InitOtherPlayer(50, 50, ""); socket.On("joinGame", (data) => { Debug.Log("recive : joinGame"); posInit p_params = new posInit(); p_params = JsonUtility.FromJson <posInit>(data.ToString()); UnityMainThreadDispatcher.Instance().Enqueue(InitTheMainThread(p_params)); }); socket.On("startGame", (data) => { Debug.Log("recive : startGame"); mapInfo p_params = new mapInfo(); p_params = JsonUtility.FromJson <mapInfo>(data.ToString()); UnityMainThreadDispatcher.Instance().Enqueue(ThisWillBeExecutedOnTheMainThread(p_params)); }); socket.On("idPlayer", (data) => { Debug.Log("recive : id"); string p_params; p_params = JsonUtility.FromJson <string>(data.ToString()); gm.setMyId(p_params); }); socket.On("updateGame", (data) => { Debug.Log("recive : updateGame"); mapInfo p_params = new mapInfo(); p_params = JsonUtility.FromJson <mapInfo>(data.ToString()); UnityMainThreadDispatcher.Instance().Enqueue(ThisWillBeExecutedOnTheMainThread(p_params)); }); }
public IEnumerator InitTheMainThread(posInit p_params) { gm.InitPlayer(100, 100, ""); gm.InitOtherPlayer(50, 50, ""); gm.setMyId(p_params.idPlayer); idPlayer = p_params.idPlayer; yield return(null); }