Question by
FALA · Sep 13, 2015 at 12:37 PM ·
instantiateplayerprefsserializationsavingdata
How to save many instantiated objects position/rotation at runtime???
Hello, I want to create game like minecraft (sandbox) and I have a problem with saving a new blocks. I'm using actually this method http://answers.unity3d.com/questions/200286/how-to-save-instantiated-gameobject-.html and it works but I can save only one last block. I tried to serialize it, PlayerPrefs, saving data to text file and saving by table but my knowledge about tables is low :P Please help ^^
Comment
Answer by Vivek-Joshi · Sep 22, 2015 at 06:57 AM
bool tapOnce;
public List<GameObject> saveGameObjects;
public GameObject[] itemToSpawn;
void Update(){
if (Input.GetMouseButtonUp(0))
{
Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 5);
Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
if (tapOnce){
tapOnce=false;
int itemNo = Random.Range(0, 4);
GameObject go = Instantiate(itemToSpawn[itemNo]) as GameObject;
saveGameObjects.Add(go);
}
}
}
This works pretty well for me. Hope this helps you. Don't forget to use:
using System.Collections.Generic;
Answer by Propagant · Jan 15, 2016 at 11:42 PM
You should try to check this... https://www.youtube.com/watch?v=kQ5vh4JJFQI