Search Unity

Question Make Coin Data Saveable

Discussion in 'Scripting' started by Altanin, Sep 28, 2020.

  1. Altanin

    Altanin

    Joined:
    Jul 21, 2020
    Posts:
    15
    So I'm trying to learn about save data and how to implement different variables but I'm not sure how to write the coding for it. I followed a tutorial to create a coin system but I don't know how to write it into my playerdata script so that it gets included in my save. Can anyone point me in the right direction here?

    these are my working save/load scripts
    PlayerData - https://pastebin.pl/view/13e6c12c
    Player - https://pastebin.pl/view/c9bebb74

    & this is the Coin data that I would like to add as a saveable function

    CoinScript - https://pastebin.pl/view/a2b4e30a
    GameHandler - https://pastebin.pl/view/d4fa1ff8

    thankyouuu!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    Here's an example of simple persistent loading/saving values using PlayerPrefs:

    https://pastebin.com/icJSq5zC

    Useful for a relatively small number of simple values.