Forum rules - please read before posting.

Potential Bug

When trying to force the save system to use SaveFileHandler_SystemFile I receive this error:

Assets\Scripts\ForceSaveSystem.cs(11,42): error CS0246: The type or namespace name 'SaveFileHandler_SystemFile' could not be found (are you missing a using directive or an assembly reference?)

Here's my script:

using UnityEngine;
using AC;

public class ForceSaveSystem : MonoBehaviour
{
    void Awake()
    {
        SaveSystem.SaveFileHandler = new SaveFileHandler_SystemFile();
        Options.OptionsFileHandler = new OptionsFileHandler_SystemFile();
    }
}

I'm using Unity 2021.3.15f1 and AC 1.76. This even happens for me on a fresh AC install/new project.

Comments

  • edited December 2022

    To add: Using "SaveSystem.SaveFileHandler = new SaveFileHandler_SystemFile();" also completely breaks the PersistentEngine and makes all scripts attached, including AC's default scripts, come up with errors after a restart of Unity.

  • I cannot recreate such an issue. Check that you have only one script and class - the original from AC's "Scripts/Save system/FileHandling" folder, named SaveFileHandler_SystemFile.

    Don't run your code in Awake - it'll run before AC has loaded. Try Start instead.

  • The documentation says to place it in Awake()?

    It seems to be because the entire contents of the SaveFileHandler_SystemFile file are wrapped in #if !SAVE_IN_PLAYERPREFS so I can't add the script to the PersistentEngine unless I comment those out because it hides the MonoBehaviour class which is required to add the script to an object.

    Is it ok to comment those out?

  • It can be in Awake, provided its on the PersistentEngine.

    It seems to be because the entire contents of the SaveFileHandler_SystemFile file are wrapped in #if !SAVE_IN_PLAYERPREFS

    The directive is there to prevent compilation errors on unsupported platforms.

    You can try commenting them out - it may work - but the best way is to duplicate the script, make changes, and have your ForceSaveSystem refer to the copy.

  • Yes, it's on the persistentEngine. Thanks Chris.

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.