Hello
Please advice¨
How can i achieve to save and load different values from multiple scripts on only one button?
So i have health and player stats on one script, bullet gun ammo on another and etc...
I want when i press the save button it should save all these values in one go.
Is this possible or what is the normal approach here?
save & load multiple script values
Re: save & load multiple script values
To do this you would put multiple save calls in one method. I.e.
As this is a question about Unity buttons and programming in general rather than Easy Save, I recommend asking for more information on the Unity forums.
All the best,
Joel
Code: Select all
public void MyMethod()
{
ES3.Save("myVariable1", myScript1.myVariable1);
ES3.Save("myVariable2", myScript2.myVariable2);
// etc
}
All the best,
Joel
Re: save & load multiple script values
Thanks for reply Joel
As mentioned in other post, I have no issue with buttons, I simply could not make it work with the code.
I fixed the player position, thank you so much.
ES3 is truly powerful and nice to use..
However in the below script, i try to implement so when clicking on save, it should save both the player position and his health.
I does not save or load his health.
Please look at my code...
As mentioned in other post, I have no issue with buttons, I simply could not make it work with the code.
I fixed the player position, thank you so much.
ES3 is truly powerful and nice to use..
However in the below script, i try to implement so when clicking on save, it should save both the player position and his health.
I does not save or load his health.
Please look at my code...
Code: Select all
public void MyMethod()
{
playerHealth healthBox = pHealth.GetComponent<playerHealth>();
ES3.Save("currentHealth", healthBox.currentHealth);;
ES3.Save("playerPos", player.transform.localPosition);
// etc
}
public void LoadData()
{
playerHealth healthBox = pHealth.GetComponent<playerHealth>();
player.transform.localPosition = ES3.Load("playerPos", defaultValue);
ES3.Load<float>("currentHealth");
}
Re: save & load multiple script values
Hi there,
There is a programming mistake in your code unrelated to Easy Save. You're not assigning the output of the ES3.Load method to your health variable.
All the best,
Joel
There is a programming mistake in your code unrelated to Easy Save. You're not assigning the output of the ES3.Load method to your health variable.
All the best,
Joel
Re: save & load multiple script values
I got it to work.
Thank you Joel..
I am loving it more and more as i use it..
I can basically save all that i need
Now i need to figure out how that applies between scenes..
Cheers
Thank you Joel..
I am loving it more and more as i use it..
I can basically save all that i need
Now i need to figure out how that applies between scenes..
Cheers