Save and Load - FROM FILE in binary format [Tutorial][C#] - Unity tutorial 2019

preview_player
Показать описание
We drop that Playerprefs stuff, and instead save and load our game from a binary file directly in our folder, whatever you do with that file is now in your hands, will put it on your server? Will you store it in your server's database. Many possibilities, does anyone even read these.

Support us on Patreon, this will unlock many perks, from mention in the videos, project files, experience boost on our website and help with your work!

Want the files? You can find everything on the website!

Our team will help you make your project come to life, drop us a message and let's talk.

Join our community, chat with other developers, share your progress and ask a couple of questions

Additional posts, sneak peeks, and more behind the scene stuff on our Facebook page!

#gameDev #unityEngine #unityTutorial

___|Personal Socials|___________________________

@N3K_Michael
_______________________________________________
Рекомендации по теме
Комментарии
Автор

Thanks for taking the time to upload this video. It's been a massive help.

urhvn
Автор

Can't wait to see your new videos every day :)

abdullahkrmzyuz
Автор

Great way to pass the content, I hope you keep making more videos like this!

gamixstudios
Автор

The content quality on this channel is over 9000. Still! An other usefull video for me, thanks!

Raskelot
Автор

If anyone gets the IOException: Sharing violation error message - I've listed some possible solutions below:
1. Close any folders you have open containing data.ss
2. Close any programs that have data.ss open
3. Run Unity as admin
4. (This one worked for me) Use the using keyword when declaring your file variables in both Save() and Load()

// example of Save()
using (var file = new FileStream(saveFileName, FileMode.OpenOrCreate, FileAccess.Write))
{

formatter.Serialize(file, State);
file.Close();
}

urhvn
Автор

this is awesome, i would've loved to see a more of encrypted and extremely hard to decrypt/break type of save/load system, you might think that its safe but a lot of people nowadays know how binary works and can manage to edit it after trying a little.

lyte
Автор

I have a question if I wanted to use this save system, and I have multiple objects with similar data that were saved. How can I only get the information about one for the objects?

AngelOfChaos
Автор

Hey, when i work with this method, when i try add "new list" to save, all data have been gone because it not match StateSave variable . how to fix it?

Tamdev
Автор

I want to use this system to store the data on the amazon s3 bucket, for all my players game state, but the really problem that is bothering me, what if I want to add new features to my game, how shall the file schema change can be implemented upon the existing binary files, plz reply

sandeeproy
Автор

This C# work awesome, But if i use it with your another video with cloudsave so will it not work beforre i click on login button to log in to google play service so i can not use this code to save local when the game start and when it save, I can see in unity editor on windows that it works but if i build the apk to android so will it not work before i click login, But when i do that will i use the cloud save,

And now it not work because a instance is not set to an object and i know that worked before :(

oliverbendstrup
Автор

What if you want to save a list and a bunch of other variables? struct?

darkman
Автор

Nicee one how to save to a server like Mongodb or to mysql ?

redbeardjunior
Автор

How can I save the data, that comes from the input field?

dimirionpro
Автор

How can I save and load automatically?

syedjaforhussain
Автор

Getting a sharing violation on the path "IOException: Sharing Violation on path D:\..."

jjoff
Автор

Hi bro, can you help me make "save load" to this inventory, i tried many times but without success, i hope you could do it


This is the inventory script

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class Slot : MonoBehaviour, IPointerClickHandler
{
private GameObject inventory;

public enum property { usable, displayable, empty};
public property ItemProperty { get; set; }

private string displayImage;
public string combinationItem { get; private set; }

void Start()
{
inventory = GameObject.Find("Inventory");
}


public void eventData)
{
=
().currentSelectedSlot;
= this.gameObject;
Combine();
if (ItemProperty == Slot.property.displayable) DisplayItem();
}

public void AssignProperty(int orderNumber, string displayImage, string combinationItem)
{
ItemProperty = (property)orderNumber;
this.displayImage = displayImage;
this.combinationItem = combinationItem;
}

public void DisplayItem()
{

=
Items/" + displayImage);
}

void Combine()
{

().combinationItem
== &&
().combinationItem!= "")
{
Debug.Log("combine");
GameObject combinedItem =
("Combined Items/" + combinationItem));



ClearSlot();
}
}

public void ClearSlot()
{
ItemProperty = Slot.property.empty;
displayImage = "";
combinationItem = "";
=
Items/empty_item");
}
}

AND THIS IS THE SLOTS SCRIPT

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class Slot : MonoBehaviour, IPointerClickHandler
{
private GameObject inventory;

public enum property { usable, displayable, empty};
public property ItemProperty { get; set; }

private string displayImage;
public string combinationItem { get; private set; }

void Start()
{
inventory = GameObject.Find("Inventory");
}


public void eventData)
{


().previousSelectedSlot
().currentSelectedSlot;
= this.gameObject;
Combine();
if (ItemProperty == Slot.property.displayable) DisplayItem();
}

public void AssignProperty(int orderNumber, string displayImage, string combinationItem)
{
ItemProperty = (property)orderNumber;
this.displayImage = displayImage;
this.combinationItem = combinationItem;
}

public void DisplayItem()
{

=
Items/" + displayImage);
}

void Combine()
{

().combinationItem
== &&
().combinationItem!= "")
{
Debug.Log("combine");
GameObject combinedItem =
("Combined Items/" + combinationItem));



ClearSlot();
}
}

public void ClearSlot()
{
ItemProperty = Slot.property.empty;
displayImage = "";
combinationItem = "";`enter code here`
=
Items/empty_item");
}
}

Redha-wvfk
welcome to shbcf.ru