Forum rules - please read before posting.

global variable not saving?

Hi, I'm using AC v1.62.6, Unity 2018.1.2.

I'm a bit stuck.. I've got a global var that is changed to 'true' by script, and if I Debug.Log the variable it shows the right value but in the Adventure Creator GUI it still shows set to 'false'. I've tried setting it in multiple spots in the code without change in behavior.  If I leave and re-enter the scene, the other variables are all still set properly except this one boolean. I've tried creating a new boolean and setting that instead but get the same issue.  I've started using presets so I'm wondering if there's something about how they work that might be resetting the var or something? I'm at a loss :(

I set lots of global and local vars via script and this is the only one giving me grief.  If I start it off as 'true' it stays 'true' but I need it to flip part-way during the scene.  The code is short, and the rest of it is functioning, I've attached a picture of the log output and the highlighted var remaining unchanged:

            AC.GlobalVariables.SetBooleanValue(23, true);
            Debug.Log(AC.GlobalVariables.GetBooleanValue(23));
image

Thanks in advanced for taking a look!

Comments

  • The screenshot doesn't show enough - is the Variable linked to anything, e.g. Options Data?  Is "Show realtime values?" checked above?

    Presets should only interfere if you tell them to i.e. with the Variable: Assign preset Action or by calling AssignFromPreset through script - are either of those the case?
  • Ohh I didn't have "Show realtime values" checked, thank you so much!  Using that, I've narrowed down that my issue is the variables don't load properly when I return to the scene from another scene, it throws an error but I can't trace the error far back enough, I wonder if it has to do with the folder location of my scenes or something?  The error message is:

    The referenced script (Unknown) on this Behaviour is missing!
    UnityEngine.Resources:LoadAll(String, Type)
    AC.AssetLoader:RetrieveAssetFiles(Object[], String) (at Assets/AdventureCreator/Scripts/Static/AssetLoader.cs:204)
    AC.AssetLoader:RetrieveTextures(String) (at Assets/AdventureCreator/Scripts/Static/AssetLoader.cs:122)
    AC.AssetLoader:RetrieveAsset(Texture, String) (at Assets/AdventureCreator/Scripts/Static/AssetLoader.cs:85)
    AC.Player:LoadPlayerData(PlayerData, Boolean) (at Assets/AdventureCreator/Scripts/Character/Player.cs:760)
    AC.SaveSystem:AssignPlayerAnimData(Player) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1425)
    AC.KickStarter:SetLocalPlayerID(Player) (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1192)
    AC.KickStarter:AssignLocalPlayer() (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1288)
    AC.KickStarter:OnAwake() (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1006)
    AC.MultiSceneChecker:Awake() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:47)


    it occurs twice, once with less of a backtrace:
    The referenced script (Unknown) on this Behaviour is missing!
    UnityEngine.Resources:LoadAll(String, Type)
    AC.LevelStorage:UnloadTransformData(List`1, SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:382)
    AC.LevelStorage:SendDataToScene(SingleLevelData, Boolean, SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:119)
    AC.LevelStorage:ReturnCurrentLevelData(Boolean) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:77)
    AC.SceneSettings:OnStart() (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:129)
    AC.MultiSceneChecker:Start() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:73)

    Not sure if you have suggestions on where to go from here or if this is enough information? I'm guessing that's it not loading the saved variables.. but when I changed to the other scene it worked fine, it's just returning to this one where I lose the vars.

    Thanks!
  • The errors don't appear to be related to Global Variables - it may be a separate issue.

    The first is to do with the restoration of the player's "Portrait icon texture" - are you changing it at any point?  See the Manual's "Saving asset references" chapter for details on how to manage asset files that replace such fields at runtime.

    The second looks related to the loading of RememberTransform component data - are there any of that type in this particular scene?

    There's not much to go on just yet, but that it only occurs in one scene makes it somewhat easier to pin down.  Back up your project, then try deleting sets of objects in your scene (all except the GameEngine / MainCamera can be removed safely) until the error no longer shows.  Hopefully you can use that to narrow down the GameObject that's causing the issue.
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.