now i need to ..for each object record its level along with its position ill be able to do just about anything..
any ideas how to expand this so save a int level value for each i would be grateful this will help me understand
ill be working at this now
Code: Select all
// A List which we'll add the Transforms of our created prefabs to.
public List<Transform> prefabInstances = new List<Transform>();
public void Save()
{
// Save the number of created prefabs there are.
ES3.Save<int>(id+"count", prefabInstances.Count);
// Save our Transforms.
ES3.Save<List<Transform>>(id, prefabInstances);
// save and load the level of the tower
}
/*
* We will call this after downloading the data from the server.
*/
public void Load()
{
// Load how many prefabs we need to instantiate.
int count = ES3.Load<int>(id + "count", 0);
// If there are prefabs to load, load them.
if(count > 0)
{
// For each prefab we want to load, instantiate a prefab.
for (int i = 0; i < count; i++)
InstantiatePrefab(0);// the 0 is meant to be the level when created set the level.. it set to 0 because its not implemented yet
// Load our List of Transforms into our prefab array.
ES3.LoadInto<List<Transform>>(id, prefabInstances);
}
}
public GameObject InstantiatePrefab(int Level)
{///old demo code
var go = Instantiate(prefab);
prefabInstances.Add(go.transform);
go.GetComponent<UnitTower>().level = Level;
return go;
}