Forum rules - please read before posting.

Developing for Xbox Game Core?

Hi. I'm developing my game for Xbox Game Core. Are there any considerations I should have when developing for this platform? My main concern is the Save system. Is there already some info on that matter? Any help is appreciated. Thanks!

Comments

  • I know I must call UnityEngine.GameCore.PlayerPrefs.InitializeAsync before PlayerPrefs is called. What would be the best approach to do this?

  • Indeed, it's the save system that requires the most consideration when porting to an unsupported platform. Each platform has its own save-game requirements/restrictions, and - in the case of Xbox - these are behind NDAs.

    However, AC allows you to implement your own saving techniques - both the format (i.e. XML, Binary, Json etc), and the location (PlayerPrefs, system files, etc).

    The Manual's "Save formats and handling" chapter has the details, but essentially you can write your own implementation of the ISaveFileHandler script, plug it into SaveSystem, and AC will rely on that instead of its default.

    You can also derive from AC's provided classes, such as SaveFileHandler_PlayerPrefs, which uses the PlayerPrefs to store save game data. If you wanted to add on your own code before e.g. loading a game, you can have your script override it:

    using UnityEngine;
    using AC;
    
    public class SaveFileHandler_Custom : SaveFileHandler_PlayerPrefs
    {
    
        public override void Load (SaveFile saveFile, bool doLog, System.Action<SaveFile, string> callback)
        {
            // Custom code here, and then run the default load process
            base.Load(saveFile, doLog, callback);
        }
    
    }
    

    Alternatively, if you just need to run some custom code before AC does anything at all, you can set the first scene in your Build Settings to a new scene that runs it before then switching to the first "proper" scene of your game.

  • edited July 2024

    Where is the first time PlayerPrefs is called in AC's scripts? I need to make sure to call some code before PlayerPrefs is called for the first time.

  • The Options script's LoadPrefs function makes calls to PlayerPrefs, both from the Options data and the Save system.

    Options data is similarly handled with a separate interface subclass - OptionsFileHandler_PlayerPrefs is the default.

    All such calls are ultimately triggered from the MultiSceneChecker script's Awake function. You could try having a separate script make calls to PlayerPrefs in another Awake function (and assigning a lower Execution Order), but I'd recommend the approaches mentioned above - either injecting custom code into scripts that derive from the default implementations, or using a separate scene before opening the first "AC" scene.

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.