Forum rules - please read before posting.

Issue with Selective Load Autosave

At the beginning of the game I have a title screen where players can select their profile. When they click on a continue button I want to load only variables, so the game knows their playername, progress, etc. Unfortunately this always triggers the scene to reload or rather trigger the designated "on load" cutscene.

I saw that you fixed some issues with selective loading in 1.60 but that's also the version I'm currently working with. Is this a bug, do you need more information, does anyone know an existing workaound for this?

I'll try to set-up a different "on load" cutscene for, one that may be able to circumvent the issue, but we definitively narrowed it down to the action list element that selective loads only variables from the current autosave.

Comments

  • Which scene is reloading?  The title screen, or the scene that the player saved in?  You say you want to only load variables - are you loading the scene as well?  Please post an image of the exact Action you're using.

    When a scene is loaded due to restoring game data, the OnLoad will always trigger - it's not an option to selectively disable.  It's possible that could be altered, but if I'm not sure why you'd create an OnLoad cutscene if you don't want it to run.  Can you elaborate on the exact needs and situation here?
  • edited March 2018
    Game Start

    Scene 0 - Title Scene

    "OnLoad" calls TitleMenu
    The TitleMenu is for selecting/creating profiles and quitting only. Once a profile is created or selected, a button labeled "continue" appears that is supposed to switch from this TitleMenu to the MainMenu.

    "Continue" Button
    Was supposed to only load variables after an existing profile is selected. It's not switching scenes, only turning off one menu and turning on another. I only want the variables  https://imgur.com/iWPXVkZ and then switch the menu.
    Instead what happens is the scene I'm currently in, the Title Scene, appears to be reloaded as well by this action, ... which triggers my OnLoad, and never switches to the next menu.

    I put some blockers  https://imgur.com/Byv9YMr in my ActionList to see what happens and it looks like AC never runs the action after the selective load.

    Solution: I figured out that selecting a profile automatically loads PlayPrefs. By saving the progression-relevant variables in OptionsData I actually don't have to load anything in this scene anymore. This also allows me to use variable presets more efficiently, since it's possible to ignore variables stored in PlayerPrefs.

    Sidenote:  https://imgur.com/ZMY1sOj appears to work more reliable than  https://imgur.com/AdgeZV6 but I haven't figured out why.

    Edit: I put the links in again, because I can't see the images here.
  • Indeed - if all you're trying to do is load profile-specific variables, then linking them to Options Data is the way to go.  A tutorial on using them to create a custom graphical option can be found here.
  • While this seemed to work for a while, we have been running into the issue that again. I know it has been fixed in 1.64 but upgrading this late in the project is not an options for us. Has the selective load issue been fixed, yet? I tried to load only variables after switching profile but AC decided to load the entire autosave...
  • The selective loading feature is not comprehensive - it's not about loading only what's checked, it's about not loading what's unchecked.

    To load only variables from a save file, you need a custom script.  Something like this:



  • edited August 2018
    Thanks a bunch, using a custom action to load variables does the trick.

    Just FYI when we tried to use selective load to do this (everything but variables unchecked) it loaded the scene, maybe even the complete save, anyways.

    I don't know if this has been brought to your attention or has been fixed, yet, but switching profiles (in 1.60) may also sometimes not load inventories correctly. We already implemented a workaround for this by hardcoding inventory updates when loading important checkpoints, but the only realiable save we can work with appears to be autosave.

    Edit: I would love to give you more information, but since we are approaching a deadline and have at least a reliable workaround for everything, finding the necessary steps to reproduce these issues is currently not possible.
  • To be clear, are you switching profile *and* loading a save game?  Profiles themselves have nothing to do with inventories.
  • edited August 2018
    First we tried doing it with selective load (inventory + variables). A player would select their profile in main menu, we would tried to load their progress, before letting them start a new chapter scene where no save fiel existed yet, but ran into said problems. The missing inventory would then be cause by us no longer being able to use selective load to update progress before continuing on to a new scene. I'll try to work that into our custom action that already loads variables correctly!
    Thanks!
  • Just out of curiosity and because it's not obvious to us: How much of the last active profile is being loaded/initiated by AC managers when the game is started? Because I don't know, yet, what exactly is messing up our profiles / savegames.
  • Without loading a save game file, the game will begin with options data (sound volumes, language, subtitles state) taken from the active profile.  Any options-linked global variables will also be updated to this profile's set of values.
  • Okay, again thank you very much. With that we've definitively narrowed it down to the bug you fixed in 1.64 and can hopefully integrate the changes into 1.60 and make it work for us!
  • edited August 2018
    If you could just help us out a little one more time, we can't get it to work 100%.

    We replaced the old scripts for SaveSystem and SaveData for the new ones and fixed all the dependency issues it caused for the other classes (KickStarter, Inventory, Menu, etc.), but there must be something we are missing.

    I linked a screenshot of all the files that were updated due to this.

  • You haven't stated the problem - what's actually the issue?  Are you getting compilation errors / warnings from the Console?
  • edited August 2018
    Oh, I'm sorry, the issue is that PlayerPrefs still aren't loaded when profiles are switched. I was hoping you could maybe tell us if we forgot to update a certain script that's not on the list, or give a short description of how you fixed the issue yourself. I've searched this forum up and down and haven't found anything related to this issue other than your 1.64 release thread and this post.

    everything works, but as soon as a second profile comes into play, the first can kiss their progress goodbye.
  • You're referring to this?
    • Fixed: Global variables linked to Options Data not loading correct values upon switching save profile
    Update the Options script's SwitchProfileID method.  It should make a call to AssignOptionsLinkedVariables:

    KickStarter.runtimeVariables.AssignOptionsLinkedVariabes ();
  • Perfect, thank you very much! With this we were able to integrate the fix successfully into 1.60, issue resolved (:
  • Hi, I would like to load only variables from a save, I found this custom script @ChrisIceBox wrote, but the link to pasteall.org seems broken, can you resend this script please?

    Chris:"To load only variables from a save file, you need a custom script. Something like this: http://pasteall.org/1068777/csharp".

    Thanks!

  • I believe this was it:

    using UnityEngine;
    using System.Collections;
    using System.IO;
    using AC;
    
    public class LoadVars : MonoBehaviour
    {
    
        public int saveID = 0;
    
    
        [ContextMenu ("Load Variables")]
        private void LoadVariables ()
        {
            foreach (SaveFile saveFile in KickStarter.saveSystem.foundSaveFiles)
            {
                if (saveFile.saveID == saveID)
                {
                    if (File.Exists (saveFile.fileName))
                    {
                        StreamReader r = File.OpenText (saveFile.fileName);
    
                        string fileContents = r.ReadToEnd ();
                        r.Close ();
    
                        ACDebug.Log ("File read: " + saveFile.fileName + ", Assigning variables");
    
                        int divider = fileContents.IndexOf ("||");
                        string mainData = fileContents.Substring (0, divider);
                        SaveData saveData = (SaveData) Serializer.DeserializeObject <SaveData> (mainData);
    
                        SaveSystem.AssignVariables (saveData.mainData.runtimeVariablesData);
                    }
                }
            }
        }
    }
    
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.