Unity 3D : Saving Player Data (In 2 Minutes!!)

preview_player
Показать описание
Saving player data in Unity is important no matter how small the game - Luckily, It's also simple, easy, and fast to execute - Learn exactly how in the next 2 Minutes!!!

If you enjoyed this video, I have a small 1$ Member perk available for anyone who would like to help us save up for Facial Motion Capture :)
(Just click the "Join" Button next to "Like"!)

Free Rigged Blender Male & Female Base Model:
Blender RIGGING & ANIMATION SERIES:
Intro To Unity Programming FULL Series:

T-SHIRT LINKS HERE:

If you're a gamer, please check out my new game on steam! It took over 3 years to create and has thousands of hours and heart put into it :)

As always, thank you so much for watching, please have a fantastic day, and see you around!

- Royal Skies -
-------------------------------
Рекомендации по теме
Комментарии
Автор


Code can be found below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SaveData : MonoBehaviour
{
public TMPro.TextMeshProUGUI myScore;
public int currentScore;

void Update()
{
myScore.text = $"SCORE:
}
public void SaveScore()
{
if (currentScore >
{
PlayerPrefs.SetInt("highscore", currentScore);
}
}
}

TheRoyalSkies
Автор

I would like to add on top of the lack of security the main man wrote about up top. PlayerPrefs can be very limiting in size and type range, also can fairly easily be accessed and tinkered later on so ppl can cheat saved info in this method.
So for a simple game or demo - go for it, but if you want something more sassy look into data encryption, data structures and possibly data base transactions.

notme
Автор

really appreciate you, thank you so much for these quick and to the point tutorials!

oscarishino
Автор

I did't know Ian Hubert was making Unity Lazy Tutorials. I love it!!

GregorioGuirado
Автор

Ooh!!! Yes. I'm a step closer to releasing rythm fodder!!

Thesupperals
Автор

Like many of the comments say, you shouldn't really use player prefs for saving data longterm. It saves to the registry which isn't cool.

(Ty for the tut tho, king, it's good work as always!)

I hiiiighly highly recommend just buying Easy Save. It's worth it and then some.

ACatWithACrown
Автор

First Video, watch it halfway, +1 Sub for Royal Skies!

mrredcrafter
Автор

I’ve been using your channel for blender. The I find this god damn video. I’m using blender for my game in unity. It’s like you made it for me.

immortalhamster
Автор

I still like better to use .Net's binary classes :)

IchigoFurryModder
Автор

Good tool for saving settings. But for savegames, as others mentioned, definitely worth do some research on how to use binary classes and data structure.
Great video!

lorddiego
Автор

This is great, but how does it store the data? Does it generate a .sav file by any chance? This could be useful for a very simple saving system but I've my doubts it'd be useful in the long run, specially if you want your game to be able to save and load more than one file.

Chronomatrix
Автор

Is that also can be used to save graphics settings, and key bindings?

Radar_
Автор

I doubt this would work for larger scale things (like an entire save file), at least not without some added functionality, but seems good for quick little things.

Sleksin
Автор

What if we want the saved data to presist but if they don't click a save button they go back to a default state. Like unlocking levels. Level 1 unlocked and level 2 gets unlocked but I didn't click save so when I turn back the game it is now only level 1 unlocked not level 1 and 2. Been struggling hope to maybe get some feedback. Thank you.

wearwolf
Автор

A quick tip!


It creates a file where you specify and you can then hook it up to steam cloud. EZ PZ!
So instead of PlayerPrefs.SetInt(somePrefString, 1);
FileBasedPref.SetInt(somePrefString, 1);

(Optional) It also lets you encrypt the data :) (Do this sparingly/smartly though, as it's performance heavy to do.

TheAlienpope