Skip to content

Instantly share code, notes, and snippets.



Last active Jan 26, 2019
What would you like to do?
//MessagePack をいれとく
//GameData.Load(gameObject) GameData.Save(gameObject) で使う
public class saveDataFormat
public string name;
public Vector3 pos;
public Quaternion rot;
public Vector3 scale;
public static class GameData
public static void Save(GameObject obj)
var data = new saveDataFormat(); =;
data.pos = obj.transform.position;
data.rot = obj.transform.rotation;
data.scale = obj.transform.localScale;
var bytes = MessagePack.MessagePackSerializer.Serialize(data);
File.WriteAllBytes(Application.dataPath + "/SaveData/" + + ".bin", bytes);
public static void Load(GameObject obj)
byte[] readData = File.ReadAllBytes(Application.dataPath + "/SaveData/" + + ".bin");
var data = MessagePack.MessagePackSerializer.Deserialize<saveDataFormat>(readData);
obj.transform.position = data.pos;
obj.transform.rotation = data.rot;
obj.transform.localScale = data.scale;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.