Search Unity

Storing a variable

Discussion in 'Scripting' started by SirMarley, Aug 23, 2014.

  1. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Guys...

    Is there anyway other than using a PlayerPrefs to store a variable?

    I have this static int gold which is going to be an In App Purchase and I just need to be sure the values don´t get reset to 0 each time the user plays

    Thanks!
     
  2. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    There's heaps of ways :) Can I ask why you don't want to use PlayerPrefs though? It would be by far the simplest method if you only need to store a single integer..
     
  3. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Since it is going to store the información after the user makes a purchase, I am afraid someone can look for the info stored and change it to "have more than what they buy"
     
  4. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Yeah I can understand your concern. However, whichever way you decide to store the data, someone will be able to gain access to it with enough determination. You could store it in PlayerPrefs but obfuscate the value by encrypting it, which will make it harder for honest thieves, but again, it wont stop anyone with enough determination.
     
  5. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Do you know any good way to encrypt them and to decrypt them when the game needs to retrieve that info?
     
  6. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    There's quite a few. Base64 is very simple and easy to implement, maybe too simple tbh.. but it depends on how determined you think your users will be to access the data. There's also AES and more.. a quick search should bring up the various algorithms out there.