public void Load(PersistableObject o) { Debug.Log("Loading file: " + this.savePath); #if UNITY_WEBGL if (!PlayerPrefs.HasKey("0")) { Debug.Log("First time playing. Loading canceled!"); return; } o.Load(new GameDataReader(null)); #else if (!File.Exists(this.savePath)) { Debug.Log("First time playing. Loading canceled!"); return; } using ( var reader = new BinaryReader(File.Open(savePath, FileMode.Open)) ) { o.Load(new GameDataReader(reader)); } #endif }
public void Load(PersistableObject o) { byte[] data = File.ReadAllBytes(savePath); BinaryReader reader = new BinaryReader(new MemoryStream(data)); o.Load(new GameDataReader(reader)); // Load Version }
public void Load(GameDataReader reader) { // get world position //GetComponent<Camera>().getWorldPosition(); int count = reader.ReadInt(); Debug.Log("Count is: " + count); for (int i = 0; i < count; i++) { // need to handle differenct objects Debug.Log("Load object:" + i); // todo - check for type to decide if text should be read or not (else we will get corrupt readings from file) PersistableObject o = new PersistableObject(); o.Load(reader); objects.Add(o); // Add obj to map (need cloud anchors) TextObj.transform.localPosition = o.localPosition; TextObj.transform.localRotation = o.localRotation; TextObj.transform.localScale = o.localScale; TextObj.transform.GetChild(0).GetComponent <TMP_Text>().text = "I AM AT INDEX " + i; Instantiate(TextObj); } }
public void Load(PersistableObject o) { using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) { o.Load(new GameDataReader(reader)); } }
public void Load(PersistableObject o) { byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(new MemoryStream(data)); o.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public void Load(PersistableObject pO) { using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) { pO.Load(new GameDataReader(reader, -reader.ReadInt32())); } }
public void Load(PersistableObject obj) { byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(File.Open(savePath, FileMode.Open)); obj.Load(new GameDataReader(reader, reader.ReadInt32())); }
public void Load(PersistableObject o) { //load에서 using을 활용하면, game에서 코루틴을 활용한 load에 문제가 생기므로, buffer를 사용해서 임시로 데이터 저장 byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(new MemoryStream(data)); o.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public void Load(PersistableObject o) { using ( //automatically handle exception of closing file BinaryReader reader = new BinaryReader(File.Open(savePath, FileMode.Open)) ) { o.Load(new GameDataReader(reader)); } }
/// <summary> /// 读取可存储的个体 /// </summary> /// <param name="o">待读取的个体</param> public void Load(PersistableObject o) { // 将所有数据读到内存数组 byte[] data = File.ReadAllBytes(m_savePath); // 创建内存流用数组初始化,并构建基于内存的BinaryReader var reader = new BinaryReader(new MemoryStream(data)); // 按原样应用存档数据 o.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public void Load(PersistableObject obj) { // using(var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) { // obj.Load(new GameDataReader(reader, -reader.ReadInt32())); // } byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(new MemoryStream(data)); obj.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public void Load(PersistableObject obj) { using ( var reader = new BinaryReader(File.Open(savePath, FileMode.Open)) ) { obj.Load(new GameDataReader(reader, -reader.ReadInt32())); } Debug.Log("Loaded!"); }
public void Load(PersistableObject persistableObject) { //using used from catlikecoding instead of try and catch so there is always a reader available using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) { //read the version from the memory and negate it int version = -reader.ReadInt32(); //load the input persistable object with the "using" reader and the version we already got from the savefile persistableObject.Load(new GameDataReader(reader, version)); } }
public override void Load(DataReader reader) { int count = reader.ReadInt(); for (int i = 0; i < count; ++i) { PersistableObject cube = Instantiate(perfab_); cube.Load(reader); objects_.Add(cube); } }
public override void Load(GameDataReader reader) { int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PersistableObject o = Instantiate(prefab); o.Load(reader); objects.Add(o); } }
public override void Load(GameDataReader reader) { BeginNewGame(); int count = reader.ReadInt(); for (int i = 0; i < count; ++i) { PersistableObject o = Instantiate(prefab); o.Load(reader); objectsList.Add(o); } }
private IEnumerator LoadInternal(PersistableObject o) { using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) { o.Load(new DataReader(reader, -reader.ReadInt32())); while (o.IsBusy) { yield return(null); } } }
public void Load(PersistableObject o) { // using ( // var reader = new BinaryReader(File.Open(savePath, FileMode.Open)) // ) { // o.Load(new GameDataReader(reader, -reader.ReadInt32())); // // o.Load(new GameObject().AddComponent<GameDataReader>().Init(reader)); // } byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(new MemoryStream(data)); o.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public void Load(PersistableObject o) { //不可用代码 //using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open))) //{ //由于使用了using,在o.Load调用完之后会自动释放reader,之后通过协程读取关卡数据时会失败 // o.Load(new GameDataReader(reader, reader.ReadInt32())); //} //一次性读取整个文件对其进行缓冲,然后再从缓冲区中读取,所以不必担心释放文件, //只需将其全部内容存储在内存中一段时间。 byte[] data = File.ReadAllBytes(savePath); var reader = new BinaryReader(new MemoryStream(data)); o.Load(new GameDataReader(reader, -reader.ReadInt32())); }
public override void Load(GameDataReader reader) { Debug.Log("Loading..."); int count = reader.ReadInt(); Debug.Log(count); for (int i = 0; i < count; i++) { Debug.Log(i); PersistableObject o = Instantiate(prefab); o.Load(reader); objects.Add(o); } }
// Ignore any IO error protected override void loadGame() { newGame(); using (var reader = new BinaryReader(File.Open(dataFile, FileMode.Open))) { var gameReader = new GameDataReader(reader); int count = gameReader.ReadInt(); for (int i = 0; i < count; i++) { PersistableObject spawn = Instantiate(prefab); spawn.Load(gameReader); objects.Add(spawn); } } }
public void Load(PersistableObject po) { var reader = new BinaryReader(File.Open(savePath, FileMode.Open)); po.Load(new DataReader(reader)); }