Forum rules - please read before posting.

Modifying SaveSystem scripts for PlayerPrefs on Xbox. Is this enough?

edited August 2024 in Technical Q&A

Hi. If I understand correctly, PlayerPrefs uses the Xbox API under the hood (According to official Unity support in the Unity Game Core forums). So I think I could just use AC's Save system as is with only some slight modifications to the scripts.

I modified SaveSystem.cs and SaveFileHandler_SystemFile.cs to include UNITY_GAMECORE.

Like this:

if UNITY_WEBPLAYER || UNITY_WINRT || UNITY_WII || UNITY_PS4 || UNITY_WSA || UNITY_WEBGL || UNITY_GAMECORE

define SAVE_IN_PLAYERPREFS

endif

if UNITY_WEBPLAYER || UNITY_WINRT || UNITY_WII || UNITY_PS4 || UNITY_WSA || UNITY_GAMECORE

define SAVE_IN_PLAYERPREFS

endif

Is that enough? Or are there any other scripts that I should modify? Or should I approach this in an entirely different way?

Sorry about the formatting.

Comments

  • You don't need to modify AC's core scripts to alter which Save File Handler it uses. The following code, run at the beginning of your game, will do this:

    AC.SaveSystem.SaveFileHandler = new SaveFileHandler_PlayerPrefs ();
    

    I can't say if AC's PlayerPrefs implementation is all you need for an XBox port, but if you need to make modifications to it, you can create a C# script that derives from SaveFileHandler_PlayerPrefs, make the necessary overrides, and then assign it as above.

    For full details on how custom save formats and handlers can be incorporated into your game, see the Manual's "Custom save formats and handling" chapter.

  • In what script is that code run? Or do you mean I need to run it myself to switch SaveFileHandler? I imagine I would need to do that too if I want to switch to a custom save system. Is that right?

  • What methods of the iSaveHandler are required for any console? Are all necessary and I need to find the corresponding ways to implement the console API?

  • In what script is that code run? Or do you mean I need to run it myself to switch SaveFileHandler? I imagine I would need to do that too if I want to switch to a custom save system. Is that right?

    To force-set the Save File Handler, whether to a built-in class, or a custom one, run the code above in an Awake function on a component attached to your PeristentEngine prefab. The Manual chapter I mentioned has details.

    What methods of the iSaveHandler are required for any console? Are all necessary and I need to find the corresponding ways to implement the console API?

    Any script that implements ISaveFileHandler will need to implement all of its functions - you can open up the interface script for comments on each of them.

    If you use one of AC's provided classes as a base class (for example, SaveFileHandler_PlayerPrefs), then you already have implementations and can just override what you need.

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.