playMaker

Author Topic: How can I keep my game options saved? [SOLVED]  (Read 1886 times)

Silicon Power

  • Full Member
  • ***
  • Posts: 186
How can I keep my game options saved? [SOLVED]
« on: September 27, 2017, 08:19:03 PM »
Hey guys, let say for example my game has an option to select between gamepad or keyboard controllers and everything is good except I can't save this options! so everytime I close game I must re-setup all options again because my global variable can't save its value.   :'(
« Last Edit: September 29, 2017, 02:18:47 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How can I keep my game options saved? (Global variables can't keep changes)
« Reply #1 on: September 28, 2017, 03:59:55 AM »
hi,
For this you can use playerprefs actions.

playerprefs is perfect for this, but not for saving scores/coins/etc... as it is very easy to hack.
It is ideal for preferences :)

so at the start of your game you need to use a 'has key' 1st to see if the key reference exists.
if not you can do a 'default' save.

then if it does exists the you can get the value with a playerprefs get action and if you change the value you need to use playerprefs set actions.

to reset (delete all saved data)  you can use playerprefs  Delete All

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How can I keep my game options saved? (Global variables can't keep changes)
« Reply #2 on: September 28, 2017, 07:03:00 AM »
hi,
For this you can use playerprefs actions.

playerprefs is perfect for this, but not for saving scores/coins/etc... as it is very easy to hack.
It is ideal for preferences :)

so at the start of your game you need to use a 'has key' 1st to see if the key reference exists.
if not you can do a 'default' save.

then if it does exists the you can get the value with a playerprefs get action and if you change the value you need to use playerprefs set actions.

to reset (delete all saved data)  you can use playerprefs  Delete All

Thanks I'm going to test it soon, but can't we save a global variable value? I mean there is no way to do this? because I was planed to save all my character choices to global variables.
« Last Edit: September 28, 2017, 06:17:47 PM by Silicon Power »

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How can I keep my game options saved? (Global variables can't keep changes)
« Reply #3 on: September 28, 2017, 06:17:06 PM »
Ok playerprefs method works good for this section. But what if we going to create a big database of saved values?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How can I keep my game options saved? (Global variables can't keep changes)
« Reply #4 on: September 29, 2017, 02:18:07 AM »
Hi,
I would suggest getting the Easy Save asset