Hello,
I’m looking for a solution to this problem, I’m quite a novice in the world of programming, so I’ll probably see quite absurd errors in my code.
For now I managed to save the data and store it in a JSON file, but then when I want to upload it again is not distributed in every object in the scene.
With a single object in the scene works perfectly, but with several using arrays because it is not finished working.
Any suggestions?
Thank you very much for reading me!
(I’m not English…)
If you do not understand my situation I can teach you more parts of the code, I use 3 scripts to save and load the data.
1 script that has each object in the scene that collects the transform component and sends it to the script where it stores them in arrays, and then the script to save and store it in the JSON file uses them.
public void CargaDeDatos() //This will load the data to the objects to update them, this is where the error occurs.
{
foreach(var obj in ListaDeObjetos)
{
//obj.GetComponent<saveData>().posicion = obj.GetComponent<Transform>().position;
//obj.GetComponent<saveData>().posicion = PosicionObj;
foreach(var posoj in PosicionObj)
{
obj.GetComponent<saveData>().posicion = posoj;
obj.GetComponent<saveData>().CargaDeDatos();
Debug.Log("datos de posicion cargados");
}
//obj.GetComponent<Transform>().localPosition = PosicionObj;
}
foreach(var obj in ListaDeObjetos)
{
foreach(var posoj in RotacionObj)
{
obj.GetComponent<saveData>().rotacion = posoj;
obj.GetComponent<saveData>().CargaDeDatos();
Debug.Log("datos de posicion cargados");
}
}
foreach(var obj in ListaDeObjetos)
{
foreach(var posoj in EscalaObj)
{
obj.GetComponent<saveData>().tamano = posoj;
obj.GetComponent<saveData>().CargaDeDatos();
Debug.Log("datos de posicion cargados");
}
//obj.GetComponent<Transform>().localScale = EscalaObj[a];
Debug.Log("datos de escala cargados");
}
//VaciarDatos();
}