TABLEOFCONTENTS
ARTICLES
ABOUTTHELIBRARY
GETTINGSTARTED
FREQUENTLYASKEDQUESTIONS
SUPPORT
APIDOCUMENTATION
SAVEGAMEUTILCLASS
Setup
Init
RegisterSaveFileModel
SetSaveFilesSubFolder
SetSaveFilesExtension
GetFullSaveFilePath
GetSaveGameNameandExists
Delete
Load-Save
Save
SaveAsync
Load
LoadAsync
Encryption
EnableEncryption
DisableEncryption
IsEncryptionEnabled
FURTHERINFORMATIONONUSE
THESAVEGAMEDATAMODEL
1. Articles
1.1.AbouttheLibrary
TheSimpleComplexSaveGameUtilallowsyoutoload,save,encryptand
decryptverycomplexandlargedatamodels.Thesedatamodelscancontainlists
anddictionarieswithcomplexdatatypesandcircularreferences.Inadditionto
synchronoussave/load,asynchronousload/saveisalsosupported.
Thelibrarywasdevelopedtoallowaveryfastintegrationintoyourproject.
Forthisreasone.g.theNewtonsoft.Json.dllwasembeddedintothelibrary.This
wasdonetoavoidanyversionconflictswithotherlibrariesyouusethatuse
NewtonsoftJson.
ThelibraryprovidesanaccessibleclasscalledSaveGameUtil.Thisclassloads,
storesandencryptsyoursavedgames.
1.2.GettingStarted
Developedtoeliminatetheproblemsofstoringcomplexsavegames.
Inthefollowingstepsyouwilllearnhowtoproceed,whatyouneedtodoto
achieveasmoothintegrationintoyourproject.
Theassetcontainsademo.Itconsistsofanexamplescriptthatillustrateshowto
useSaveGameUtilusingacomplexdatamodel.Thereisalsoademoscenethat
showshowtosave,loadanddeletethesaveddata.
Ifyouhavealreadydownloadedandinstalledtheasset,youcanskipstep1.
1. DownloadtheassetfromtheAssetStoreandimportitintoyourproject.
2. AddthenamespacenamedPWHSoftSaveGametoyourclass.
IfyouhavenotyetcreatedaMonoBehaviourscript,createone.
3. CreatetheStart()methodinyourscriptandcalltheInit()methodof
SaveGameUtil.
TheInit()methodmustalwaysbeexecutedfromamainthread.
4. Createamodelinwhichyouwanttosaveyoursavegamedata.
5. Registeryourmodel.ThebestwaytodothisistousetheInit()method
withintheStartmethod.
Info:Withthisstepyouhavealreadysetupeverythingthatyoucanloadand
savesaveddata.
6. Nowyoucancheckwhethertheplayerhasalreadyplayedthegameby
tryingtoloadthegame.
Iftheresultiszero,theplayerhasneverplayedthegamebeforeandyou
cancreateandsaveanewsavelevel.
Itisbesttodefineanewmethodcalled"Load"inyourscript.Youcanthen
callthismethodviathestartmethodaftertheRegisterSaveFileModel.
7. If,forexample,youhaveaddedanewscoretothedatamodelaftera
gamesession,youshouldsavethedata.Werecommendthatyousavethe
gameasynchronouslytoensureasmoothgamingexperienceforyour
customers.Youshouldalsowritethisinapublicmethodwithinyour
script,asyoucanalsocallthisfunctionfromtheUI.
ThesestepshaveillustratedtheeasyhandlingofSaveGameUtil.However,
thistooloffersmanymorepossibilitiessuchasencryptingthesavegame(see
chapter2.1.3.1).Furtherinformationaboutthefunctionalitycanbefoundin
thedemoproject.
1.3.FrequentlyAskedQuestions
Sincethisisthefirstdocumentversionandnoquestionshavebeenaskedyet,
theywillbeupdatedwiththenextversion.
1.4.Support
Ifyouhaveanyquestions,pleasecontactuswithnameandsubject"Request
SimpleComplexSaveGameSupport"tothefollowinge-mailaddress:
support.unityassetstore@pwhsoft.de
Iwillansweryoure-mailassoonaspossible.Pleaseunderstandthatthismay
takesometime.
2. ApiDocumentation
2.1.SaveGameUtilClass
2.1.1.Setup
2.1.1.1. Init
TheInitmethodinitializestheSaveGameUtil.Thismethodmybeexecuted
oncebeforecallingotherfunctionsofthisclass.Thismethodshouldbeexecuted
fromthemainthread.Werecommendtocallthismethodatthestartofthe
application.
TheparameterapplicationPath:stringisoptional.Itsetsthedefaultpathwhere
e.g.memoryfilesarelocated.Ifthisisnotset,thedefaultvalueof
Application.PersistentPathisused.
IftheapplicationPathdirectorydoesnotexist,itwillbecreated.
Examples
//Initthesavegameutil.
SaveGameUtil.Init();
//Initthesavegameutil.
SaveGameUtil.Init(applicationPath:"C:\\Test\\");
2.1.1.2. RegisterSaveFileModel
Thismethodisusedtoregisterasavedgamemodelandmustbeexecutedbefore
actionssuchasloadingandsavingarecalled.
Examples
//Registerthesavegameclass
SaveGameUtil.RegisterSaveFileModel<TestSaveGameModel>("mainsavegame");
//Registerthesavegameclass
SaveGameUtil.RegisterSaveFileModel("mainsavegame",typeof(TestSaveGameModel));
2.1.1.3. SetSaveFilesSubFolder
Specifiesthenameofthesubfolderinwhichthestoragefilesarestored.
Thedefaultfoldernameis"savefiles".Ifthesubfolderissettozeroorempty,the
defaultsubfolderisthepersistentapplicationpathoftheInit()method.
Example
//SetsthesubfolderwithinthePersistentapplicationpath.
SaveGameUtil.SetSaveFilesSubFolder(Path.Combine("savegames","main"));