Forum rules - please read before posting.

How are options data affected by an app update?

Hello all,

as far as I understand, vars linked to options data are stored in PlayerPrefs.
Now if I

  • set the value of a global var X which is linked to options data to e.g. "4"
  • build the game
  • release the game via an app store
  • have players play it
  • update the build after a while and change the value of X from "4" to "6"
  • release the update to the app store
  • have players download the update and continue to play their quest,

will the value of X be changed to "6" (= override the previously saved PlayerPrefs) on their device then or will it remain at "4"?

Comments

  • I believe it should remain at 4. If a variable is linked to Options Data, then the value you specify in the Variables Manager is only used to set it's initial PlayerPrefs value. Once this has been saved in the user's options, it should remain as such until it's specifically changed through e.g. Variable: Set Action.

    This is, of course, assuming that the PlayerPrefs data does not get reset upon updating an app. Whether this is the case or not would be down to Unity's behaviour - not AC - but I don't think it does get reset.

  • edited October 2019

    Ok, I see, Chris – thank you.

    This is, of course, assuming that the PlayerPrefs data does not get reset upon updating an app

    No, they don't get reset, not unless the app itself is deleted.

    Actually this is about releasing additional chapters to a game after its initial release (as you might have guessed) and I am looking for a way to … let's say: conditionally "change from a scene to the credits rolling" depending on how many chapters are released so far.

    Another idea then: is there an easy way to for a non-coder to integrate a global AC var with Unity's new "Remote Settings"-Addon that e.g. allows to change a AC var's value from "at home" (thus unlocking a door to new chapters without updating the game app build itself?

    https://docs.unity3d.com/Manual/UnityAnalyticsRemoteSettingsScripting.html

  • It would require coding, but not much. AC's variables are designed to be easily accessible through simple scripting - see the "Variable scripting" chapter of the Manual as well as the front page of the Scripting Guide.

    This is untested, but adapting the code on the page you linked to should allow for remote control over an integer variable used to determine the number of available chapters:

    using UnityEngine;
    using AC;
    
    public class RemoteTuningVariables : MonoBehaviour
    {
    
        public int defaultNumberOfChapters;
    
        void Start ()
        {
            RemoteSettings.Completed += HandleRemoteSettings;
        }
    
        private void HandleRemoteSettings (bool wasUpdatedFromServer, bool settingsChanged, int serverResponse){
            GVar myVariable = GlobalVariables.GetVariable ("NumberOfChapters"); // An integer variable
            myVariable.IntegerValue = RemoteSettings.GetInt ("NumberOfChapters", defaultNumberOfChapters);
        }
    
    } 
    
  • One more (unfortunately urgent) question, Chris:

    • I released an app (yes, I did!) with 10 Global Vars NOT "linked to Options Data".
    • Now I want to release an update to the app with the same 10 Global Vars changed to "linked to Options Data", because it is a much better way of handling some saves.

    Will this change take effect on the player's device when he updates the app?
    Or will it get ignored (as PlayerPrefs survive updates)?

    Thanks!

  • The change will take effect, but it'll also replace any values stored in save game files, since those variables are now no longer part of "regular" save game data.

    So when a user updates and restarts, the values should become whatever their default values are set to in the Variables Manager.

    Naturally, you should test this before pushing such an update live.

    Looking through the codebase now, though, there would be an issue with the current release in the event that the user then loads a save file made from before the update. In this situation, the variable value would revert back - because it was included in the save file at that time.

    To fix that, open up SaveSystem.cs and find the following inside the UnloadVariablesData function:

    if (fromOptions && _var.link != VarLink.OptionsData)
    {
        continue;
    }
    

    Just undeneath, add the following:

    if (!fromOptions && _var.link == VarLink.OptionsData) continue;
    

    That'll cause option-linked variables to be ignored when loading a save game file, even if they were originally part of that file.

  • Thank you, Chris - this is working now.

    And I have (and love) to thank you even more … https://adventurecreator.org/forum/discussion/10915/stromhall-noel-2020-a-logical-christmas-calendar-released

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.