Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tutorial - Data Persistence - Save & load your game state while avoiding common mistakes

Discussion in 'Community Learning & Teaching' started by ChrisKurhan, Jun 28, 2022.

  1. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    266


    Hey all! Happy #TutorialTuesday!

    Need persistent data across runs of your Unity game? Don't use PlayerPrefs for your game state! Here's how you can easily store your arbitrary game state in files instead.

    I've seen many tutorials that either
    1. Tell you to use PlayerPrefs to store data, or
    2. Tell you to use dangerous classes to serialize your data.
    In this video we'll look at using text-based serialization using JSON and optionally encrypt that data. I also discuss some of the pros/cons for using text-based serialization, and what you should use instead if you really want to/need to use a binary serialization technique.

    As always, the full project is available on GitHub!