private static void UpdateHead(string filepath, Head head) { HeadJSON headJSON = new HeadJSON(head); var options = JSONFileFormat.GetJsonSerializerOptions(); string json = JsonSerializer.Serialize <HeadJSON>(headJSON, options); File.WriteAllText(filepath, json); }
void OnHeadTurn(SocketIOEvent socketIOEvent) { string data = socketIOEvent.data.ToString(); HeadJSON headJSON = HeadJSON.CreateFromJSON(data); Quaternion headRotation = Quaternion.Euler(headJSON.headRotation[0], headJSON.headRotation[1], headJSON.headRotation[2]); if (headJSON.name == playerNameInput.text) { return; } GameObject p = GameObject.Find(headJSON.name) as GameObject; GameObject eye = p.transform.Find("Other Head Avator").gameObject; if (p != null) { eye.transform.rotation = headRotation; } }
void OnHeadMove(SocketIOEvent socketIOEvent) { string data = socketIOEvent.data.ToString(); HeadJSON headJSON = HeadJSON.CreateFromJSON(data); Vector3 headPosition = new Vector3(headJSON.headPosition[0], headJSON.headPosition[1], headJSON.headPosition[2]); if (headJSON.name == playerNameInput.text) { return; } GameObject p = GameObject.Find(headJSON.name) as GameObject; GameObject eye = p.transform.Find("Other Head Avator").gameObject; if (p != null) { eye.transform.position = headPosition; } }
void OnOtherPlayerHead(SocketIOEvent socketIOEvent) { string data = socketIOEvent.data.ToString(); HeadJSON headJSON = HeadJSON.CreateFromJSON(data); Vector3 headPosition = new Vector3(headJSON.headPosition[0], headJSON.headPosition[1], headJSON.headPosition[2]); Quaternion headRotation = Quaternion.Euler(headJSON.headRotation[0], headJSON.headRotation[1], headJSON.headRotation[2]); GameObject o = GameObject.Find(headJSON.name) as GameObject; if (o != null) { return; } GameObject p = GameObject.Find(headJSON.name) as GameObject; GameObject EyeCamera = p.transform.Find("Other Head Avator").gameObject; GameObject ec = Instantiate(EyeCamera, headPosition, headRotation) as GameObject; ec.transform.parent = p.transform; p.name = headJSON.name; EyeCamera.gameObject.SetActive(false); }