using UnityEngine; public sealed class PlayerData { public Gender gender = Gender.Male; public Vector3 position = Vector3.zero; public Quaternion rotation = Quaternion.identity; public byte[] Serialize() => System.Text.Encoding.UTF8.GetBytes(JsonUtility.ToJson(this)); public static PlayerData Deserialize(byte[] data, int index, int count) { try { return JsonUtility.FromJson(System.Text.Encoding.UTF8.GetString(data, index, count)); }//try end catch { return null; }//catch end }//Deserialize() end }//class end