Forum rules - please read before posting.

Avoid entirely PlayerPrefs and saving stuff in general

Hello, I'm developing a game multiplatform (PC, Switch, Xbox, PS), and for practical reasons, I'd prefer to handle everything with my own save system, even the options and player preferences (resolution, fullscreen, audio volumes, etc.).

So I wonder if there's a way to disable entirely AC to save its own things, either on PlayerPrefs, Json, Xml, whatever. Just disabling entirely whatever file written or registry enter is called by AC.

Of course I'd like to keep the ConstantID for handling buttons and other status at runtime, but not saving them on file/settings.

I've read something in the manual about it, but it feels more like changing location (i.e. moving to another path or in another format) rather than avoiding AC to save stuff in general.

Any guidance for this scope?
Thanks

Comments

  • If you don't want to rely on AC at all for saving, you'd just need to avoid using AC's SavesList element, or the use of the Save: Save or load Action.

    If you wanted to be extra-safe and disable the file-writing completely, you could implement a new IFileFormatHandler script (see the Manual's "Custom save formats and handling" chapter) and populate it with empty functions.

  • Thanks, I'll have a look. I'm not using any Save/Load Action, nor SavesList elements.
    I meant specifically for settings. I noticed AC is saving PlayerPrefs if I change my sounds slider (even if I'm handling them with my own script, but maybe because in the Settings the exposed values are automatically connected to AC). And maybe some other PlayerPrefs are handled/saved by AC engine somehow, even if I don't call the save. I'm just wondering... But I'll have a look at the manual and do the empty functions trick for the save formats handler.

  • Hey Chris, I'm getting back after some time to this thread, to finally solve the thing.

    So, I've followed the Manual for avoiding entirely AC to save stuff (especially Options/Settings into the registry, for Unity Player Prefs).

    And this is what I did:
    I created a script called "DisableAcSaving.cs" and I've attached it to the Persistent Engine prefab, with an Awake that does the following:

    SaveSystem.FileFormatHandler = new OverrideAcSave();
    SaveSystem.OptionsFileFormatHandler = new OverrideAcSave();
    SaveSystem.SaveFileHandler = new OverrideAcSave();
    Options.OptionsFileHandler = new OverrideAcSave();
    

    Then I've a class called OverrideAcSave, which is not attached to anything (it's just in the Assets folder), that basically override all the AC methods, but returning empty. This way:

    public class OverrideAcSave : MonoBehaviour, iFileFormatHandler, iSaveFileHandler, iOptionsFileHandler
    {
        public string GetSaveMethod()
        {
            return "";
        }
    
    
        public string GetSaveExtension()
        {
            return "";
        }
    
    
        public virtual string SerializeObject<T>(object dataObject)
        {
            return string.Empty;
        }
    
    
        public virtual T DeserializeObject<T>(string dataString)
        {
            return default(T);
        }
    
    
        public virtual string SerializeAllRoomData(List<SingleLevelData> dataObjects)
        {
            return "";
        }
    
    
        public virtual List<SingleLevelData> DeserializeAllRoomData(string dataString)
        {
            return null;
        }
    
    
        public virtual T LoadScriptData<T>(string dataString) where T : RememberData
        {
            return null;
        }
    
    
        public virtual string GetDefaultSaveLabel(int saveID)
        {
            return "";
        }
    
    
        public virtual void DeleteAll(int profileID)
        {
            //MUST BE EMPTY
        }
    
    
        public virtual void Delete(SaveFile saveFile, System.Action<bool> callback = null)
        {
            //MUST BE EMPTY
        }
    
    
        public virtual void Save(SaveFile saveFile, string dataToSave, System.Action<bool> callback)
        {
            //MUST BE EMPTY
        }
    
    
        public virtual void Load(SaveFile saveFile, bool doLog, System.Action<SaveFile, string> callback)
        {
            //MUST BE EMPTY
        }
    
    
        public virtual bool SupportsSaveThreading()
        {
            return true;
        }
    
    
        public virtual List<SaveFile> GatherSaveFiles(int profileID)
        {
            return null;
        }
    
    
        public virtual List<SaveFile> GatherImportFiles(int profileID, int boolID, string separateProjectName, string separateFilePrefix)
        {
            return null;
        }
    
    
        public virtual SaveFile GetSaveFile(int saveID, int profileID)
        {
            return null;
        }
    
    
        protected virtual SaveFile GetSaveFile(int saveID, int profileID, bool isImport, int boolID, string separateProductName, string separateFilePrefix)
        {
            return null;
        }
    
    
        protected virtual List<SaveFile> GatherSaveFiles(int profileID, bool isImport, int boolID, string separateProductName, string separateFilePrefix)
        {
            return null;
        }
    
    
        public virtual void SaveScreenshot(SaveFile saveFile)
        {
            //MUST BE EMPTY
        }
    
    
        protected virtual void DeleteScreenshot(string sceenshotFilename)
        {
            //MUST BE EMPTY
        }
    
    
        protected virtual Texture2D LoadScreenshot(string fileName)
        {
            return null;
        }
    
    
        protected virtual string GetSaveFilename(int saveID, int profileID = -1, string extensionOverride = "")
        {
            return "";
        }
    
    
        protected virtual string GetSaveDirectory(string separateProjectName = "")
        {
            return null;
        }
    
    
        protected virtual string GetTimeString(System.DateTime dateTime)
        {
            return string.Empty;
        }
    
    
        protected virtual string LoadFile(string fullFilename, bool doLog = true)
        {
            return null;
        }
    
    
        public void SaveOptions(int profileID, string dataString, bool showLog)
        {
            //MUST BE EMPTY
        }
    
    
        public string LoadOptions(int profileID, bool showLog)
        {
            //MUST BE EMPTY
            return "";
        }
    
    
        public void DeleteOptions(int profileID)
        {
            //MUST BE EMPTY
        }
    
    
        public int GetActiveProfile()
        {
            //MUST BE EMPTY
            return 0;
        }
    
    
        public void SetActiveProfile(int profileID)
        {
            //MUST BE EMPTY
        }
    
    
        public bool DoesProfileExist(int profileID)
        {
            //MUST BE EMPTY
            return true;
        }
    
    
        private string GetPrefKeyName(int profileID)
        {
            //MUST BE EMPTY
            return "";
        }
    }
    

    Is that it? Do I risk to break everything this way? Having errors during the gameplay? Or is it good to go?

    P.S. I'm not calling at any time any Save: Save or Load AC Action, and I'm storing my settings and whatnot on separate files, with my own classes and methods.

  • edited March 2023

    UPDATE
    I get the following error:
    NullReferenceException: Object reference not set to an instance of an object
    AC.SaveSystem.GetNumSlots () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1150)

    Uhmm...

  • Uhmm...

    Replace:

    public virtual List<SaveFile> GatherSaveFiles(int profileID)
    {
        return null;
    }
    

    with:

    public virtual List<SaveFile> GatherSaveFiles(int profileID)
    {
        return new List<SaveFile> ();
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.