public AT_Save CreateSaveObject() { AT_Save save = new AT_Save(); //Spesific_Objects spesific_obj = new Spesific_Objects(); //save.init(id, position, rotation, scale); //saveable_objects.Save(id); //PlayerPrefs.SetInt("ObjectCount", the_saveable_objects.Count); for (int i = 0; i < the_saveable_objects.Count; i++) { //save.id = the_saveable_objects[i].id = 1; //save.position = saveable_objects.position + transform.position; //save.scale = saveable_objects.scale + transform.localScale; //save.rotation = saveable_objects.rotation = transform.localRotation; //the_saveable_objects[i].Save(save.id, save.position, save.rotation, save.scale); //the_saveable_objects[i].position + transform.position; //the_saveable_objects.scale[] + transform.localScale; //the_saveable_objects.rotation = transform.localRotation; } save.name = saveable_objects.name; save.id = saveable_objects.id; save.current_object = saveable_objects.current_object; save.position = saveable_objects.position; save.rotation = saveable_objects.rotation; save.scale = saveable_objects.scale; save.colour = saveable_objects.colour; save.material = saveable_objects.material; save.new_material = saveable_objects.new_mat; save.drawable_sprite = saveable_objects.drawable_sprite; save.drawable_texture2D = saveable_objects.drawable_texture2D; //Debug.Log("id:" + the_saveable_objects.Count); return(save); }
public void Load() { if (File.Exists(Application.dataPath + "/JSONData.text")) { //LOAD THE GAME StreamReader sr = new StreamReader(Application.dataPath + "/JSONData.text"); string Json_String = sr.ReadToEnd(); sr.Close(); //Convert JSON to the Object(save) AT_Save save = JsonUtility.FromJson <AT_Save>(Json_String);//Into the Save Object Debug.Log("-=-=-=-LOADED-=-=-=-=-"); //int object_limit = saveable_objects.id; saveable_objects.name = save.name; saveable_objects.id = save.id; saveable_objects.current_object = save.current_object; saveable_objects.transform.position = new Vector3(save.position.x, save.position.y, save.position.z); saveable_objects.transform.localScale = new Vector3(save.scale.x, save.scale.y, save.scale.z); saveable_objects.transform.rotation = new Quaternion(save.rotation.x, save.rotation.y, save.rotation.z, save.rotation.w); saveable_objects.colour = save.colour; saveable_objects.material = save.material; saveable_objects.new_mat = save.new_material; saveable_objects.drawable_sprite = save.drawable_sprite; saveable_objects.drawable_texture2D = save.drawable_texture2D; //for (int i = 0; i < object_limit ; i++) //{ //} } else { Debug.Log("NOT FOUND FILE"); } }
public void Save() { //* PlayerPref Way *\\ //PlayerPrefs.SetInt("ObjectCount", the_saveable_objects.Count); //for (int i = 0; i < the_saveable_objects.Count; i++) //{ // the_saveable_objects[i].Save(i); // the_saveable_objects[i].Save(id, position, rotation, scale); //} //* JSON Way *\\ AT_Save save = CreateSaveObject(); string Json_String = JsonUtility.ToJson(save); StreamWriter sw = new StreamWriter(Application.dataPath + "/JSONData.text"); sw.Write(Json_String); sw.Close(); Debug.Log("-=-=-=-SAVED-=-=-=-"); }