Forum rules - please read before posting.

JSON Invalid Value Error from SaveSystem Script?

I'm getting an error that appears to prevent my character from moving on the NavMesh in scenes. The error occurs in every scene. I'm using Adventure Creator version 1.80.5

The console error > ArgumentException: JSON parse error: Invalid value error UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) (at <87781e9b12134dbc9598174129a79531>:0)

The error traces to line 738 of the script SaveSystem.cs which is in the folder Assets > AdventureCreator > Scripts > Save system

That line calls a coroutine named InitAfterLoadCo and passes a saveID as an argument.

This is a deal where I wasn't noticing any problem when I stepped away from the project yesterday, but today when I went to resume work it started throwing this error and I have no idea why. I've been troubleshooting this on the Unity forums and other places for about 8 hours with no solution.

Is this a known issue by chance, and is there any way to clear this error?

Comments

  • Welcome to the community, @tis_I_jb.

    I'll need some more details about the issue to get to the bottom of this.

    Could you let me know the exact error message that appears - stacktrace included - as well as your Unity versions, the time this message appears, and the behaviour in-game that occurs as a result?

    Is it just movement that is prevented, or are Hotspots / Menus etc also unresponsive?

    What OS are you working, what is your Build Target, and are you using a custom script to rely on Json for your save-files?

  • edited April 29

    Hotspots are not functioning on mouseover, and the click-to-move functionality using the NavMesh does not respond. The scene does load and run animations, etc., but the scene does not respond to anything from the mouse.

    I tried to fix it "the cheap way," by rolling back to and downloading an earlier version of the project I had backed up on Unity Version Control, but after the download, the same problem occurs.

    Selecting the error in the Console gives the following text, in addition to what I posted above:
    ArgumentException: JSON parse error: Invalid value.
    UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) (at <87781e9b12134dbc9598174129a79531>:0)
    UnityEngine.JsonUtility.FromJson[T] (System.String json) (at <87781e9b12134dbc9598174129a79531>:0)
    AC.Templates.GraphicOptions.GraphicOptionsUI.GetSaveData () (at Assets/AdventureCreator/Scripts/Templates/GraphicOptions/Assets/Scripts/GraphicOptionsUI.cs:230)
    AC.Templates.GraphicOptions.GraphicOptionsUI.Apply () (at Assets/AdventureCreator/Scripts/Templates/GraphicOptions/Assets/Scripts/GraphicOptionsUI.cs:78)
    UnityEngine.Events.InvokableCall.Invoke () (at :0)
    UnityEngine.Events.UnityEvent.Invoke () (at :0)
    AC.ActionEvent.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionEvent.cs:39)
    AC.ActionList+d__46.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:466)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:408)
    AC.RuntimeActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:181)
    AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:279)
    AC.RuntimeActionList:DownloadActions(ActionListAsset, Conversation, Int32, Boolean, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:136)
    AC.AdvGame:RunActionListAsset(ActionListAsset, Conversation, Int32, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:242)
    AC.AdvGame:RunActionListAsset(ActionListAsset, Int32, Int32) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:163)
    AC.ActionListAsset:Interact() (at Assets/AdventureCreator/Scripts/ActionList/ActionListAsset.cs:546)
    AC.EventBase:Run(Object[]) (at Assets/AdventureCreator/Scripts/Events/EventBase.cs:126)
    AC.EventBase:Run() (at Assets/AdventureCreator/Scripts/Events/EventBase.cs:49)
    AC.EventBeginGame:OnBeginGame() (at Assets/AdventureCreator/Scripts/Events/Events/EventBeginGame.cs:38)
    AC.EventManager:Call_OnBeginGame() (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:2144)
    AC.StateHandler:PlayGlobalOnStart() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:613)
    AC.SceneSettings:PlayStartCutscene() (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:336)
    AC.SceneSettings:OnStart() (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:110)
    AC.d__51:MoveNext() (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:830)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    AC.SaveSystem:InitAfterLoad(Int32) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:738)
    AC.MultiSceneChecker:RunStartProcess() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:122)
    AC.MultiSceneChecker:Start() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:54)

  • Thanks for the details.

    This looks to be related to the Graphic Options UI's "Global String Variable", which stores its related data.

    By default, this should be linked to a Global String Variable named "GraphicOptionsData" - is this being overwritten elsewhere by e.g. any other Actions?

    This may not fix it completely, but should at least prevent it resulting in the game locking, and may help pinpoint the cause.

    Inside the /AdventureCreator/Scripts/Templates/GraphicOptions/Assets/Scripts/GraphicOptionsUI script, look for the following around line 230:

    GraphicOptionsData graphicOptionsData = JsonUtility.FromJson<GraphicOptionsData> (optionsDataString);
    return graphicOptionsData;
    

    Replace it with the following:

    try
    {
        GraphicOptionsData graphicOptionsData = JsonUtility.FromJson<GraphicOptionsData> (optionsDataString);
        return graphicOptionsData;
    }
    catch
    {
        ACDebug.LogWarning ("Variable " + globalStringVariable + " has invalid value: " + optionsDataString);
    }
    

    What shows in the Console now?

  • Thanks for your response and your help, Chris!

    I cannot think of any settings that got changed on any menus, or any option that got selected anywhere, but if there is something to check in the AC Game Editor panel or other places, please let me know.

    Edited Script
    I found the script GraphicsOptionsUI in the folder AdventureCreator > Scripts > Templates > Assets > Scripts and I commented out lines 230 & 231.

    I then pasted in your suggested new code on line 233, and it goes to 241.

    That new code did clear the error and the game seems to play normally now. There are no errors in the console. Comments in the Console are pasted below.

    A Word About These Animators
    The animator comments are most likely unrelated to this issue, but I'll include them anyway just in case they give some enlightenment.

    As background I have a player character (temporarily using Brain from the tutorials) and two NPCs, Eva and Kim.

    I believe them to be due to the fact that I created an empty parent Game Object for each of the NPCs, and placed their 3D models inside their respects GOs. The game objects are what were identified in the wizard, and that is probably why there are multiple animators on the two characters. There is one animator component on the game object, and one on the 3D model prefab for the character.

    That is something I'll clean up in later development, but that is why I believe those two comments appear below. I include them only to be thorough.

    In the console are the following comments:

    1
    Multiple Animator components detected on the character 'Kim' - the one on object 'Kim' will be used.

    -> AC debug logger
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:23)
    AC.Char:_Awake () (at Assets/AdventureCreator/Scripts/Character/Char.cs:604)
    AC.NPC:Awake () (at Assets/AdventureCreator/Scripts/Character/NPC.cs:60)

    2
    Multiple Animator components detected on the character 'Eva' - the one on object 'Eva' will be used.

    -> AC debug logger
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:23)
    AC.Char:_Awake () (at Assets/AdventureCreator/Scripts/Character/Char.cs:604)
    AC.NPC:Awake () (at Assets/AdventureCreator/Scripts/Character/NPC.cs:60)

    3
    PlayerPrefs Key 'AC_StandUp_Prototype_1_0' loaded

    -> AC debug logger
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:23)
    AC.OptionsFileHandler_PlayerPrefs:LoadOptions (int,bool) (at Assets/AdventureCreator/Scripts/Options/OptionsFileHandler_PlayerPrefs.cs:39)
    AC.Options:LoadPrefsFromID (int,bool,bool) (at Assets/AdventureCreator/Scripts/Options/Options.cs:185)
    AC.Options:LoadPrefs () (at Assets/AdventureCreator/Scripts/Options/Options.cs:118)
    AC.Options:OnInitPersistentEngine () (at Assets/AdventureCreator/Scripts/Options/Options.cs:39)
    AC.StateHandler:Initialise (bool) (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:113)
    AC.KickStarter:SetPersistentEngine () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:178)
    AC.KickStarter:Initialise () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1104)
    AC.MultiSceneChecker:Awake () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:45)

    4
    PlayerPrefs Key 'AC_StandUp_Prototype_1_0' saved

    -> AC debug logger
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:23)
    AC.OptionsFileHandler_PlayerPrefs:SaveOptions (int,string,bool) (at Assets/AdventureCreator/Scripts/Options/OptionsFileHandler_PlayerPrefs.cs:25)
    AC.Options:SavePrefsToID (int,AC.OptionsData,bool) (at Assets/AdventureCreator/Scripts/Options/Options.cs:110)
    AC.Options:SavePrefs (bool) (at Assets/AdventureCreator/Scripts/Options/Options.cs:90)
    AC.GVar:Upload (AC.VariableLocation,AC.Variables) (at Assets/AdventureCreator/Scripts/Variables/GVar.cs:310)
    AC.GlobalVariables:UploadAll () (at Assets/AdventureCreator/Scripts/Static/GlobalVariables.cs:64)
    AC.SaveSystem:AssignVariables (string,bool) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1871)
    AC.RuntimeVariables:AssignOptionsLinkedVariables () (at Assets/AdventureCreator/Scripts/Variables/RuntimeVariables.cs:197)
    AC.RuntimeVariables:OnInitPersistentEngine () (at Assets/AdventureCreator/Scripts/Variables/RuntimeVariables.cs:43)
    AC.StateHandler:Initialise (bool) (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:115)
    AC.KickStarter:SetPersistentEngine () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:178)
    AC.KickStarter:Initialise () (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1104)
    AC.MultiSceneChecker:Awake () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:45)

    5
    Spawned instance of Player 'Brain'.

    -> AC debug logger
    UnityEngine.Debug:Log (object,UnityEngine.Object)
    AC.ACDebug:Log (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:23)
    AC.PlayerSpawner/d__6:MoveNext () (at Assets/AdventureCreator/Scripts/Character/PlayerSpawner.cs:273)
    AC.PlayerSpawner/d__2:MoveNext () (at Assets/AdventureCreator/Scripts/Character/PlayerSpawner.cs:143)
    AC.SaveSystem/d__51:MoveNext () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:760)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.SaveSystem:InitAfterLoad (int) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:738)
    AC.MultiSceneChecker:RunStartProcess () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:122)
    AC.MultiSceneChecker:Start () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:54)

  • "By default, this should be linked to a Global String Variable named "GraphicOptionsData" - is this being overwritten elsewhere by e.g. any other Actions?"

    I have no idea what would have caused the change in the project's behavior. If there is any menu option, check box, or selection anywhere in an inspector panel or editor interface that could have produced such a result, then I suppose it is possible that I inadvertently caused it in a moment of carelessness, but I have not attempted to adjust or customize the default UI in the project.

    Nor have I written any scripts for the project. I cannot think of what may have caused this.

    Anyway, if there is any further checking you'd like me to do, please let me know. Thanks again!

  • The Player component's Animator (optional) can be used to specify which Animator to use - this will remove ambiguity and stop the warnings.

    I suppose it is possible that I inadvertently caused it in a moment of carelessness, but I have not attempted to adjust or customize the default UI in the project.

    Oddly, the code change should have replaced the error with a regular log message - if nothing changed, check the value of the "GraphicOptionsData" string variable in the Variables Manager. You can check Show realtime values? to have it show the "live" value while in Play mode.

    After selecting this variable in the Manager, is its Link to correctly set to Options Data? The installation process should have handled this automatically.

    Back in Edit mode, you can also click the "cog" icon beside the variable and select Find references to have AC search your project for any references that may be being made to it, outside of the Graphic Options UI component.

  • "Oddly, the code change should have replaced the error with a regular log message"

    That's what I expected too. Running it again, I do see it listed as a warning. I probably had warnings suppressed from the Console before, and was only looking at comments. Apologies for that.

    Warning: Variable GraphicOptionsData has invalid value: False

    In the AC Game Editor panel, sub-panel Variables, Global tab I do see the global variable GraphicOptionsData. Selecting it I see the following properties:

    In Edit Mode
    Label: GraphicOptionsData
    Type: String
    Initial Value: [Blank]
    Values can be translated?: [Unchecked]
    Replacement token: [var:0] (not editable)
    Link to: Options Data
    Note: This Variable will be stored in PlayerPrefs, and not in saved game files.
    Internal description: [Blank]

    In Play Mode
    Label: GraphicOptionsData (not editable)
    Type: String (not editable)
    Current value: False
    Replacement token: [var:0] (not editable)
    Links to: OptionsData (not editable)

    I do not see any option to show realtime values, but it appears to be showing the value in realtime when in play mode since the string value False appears in the editable field there.

    Back in edit mode, and selecting the variable's cog icon to run the search for references did run a check through all the scenes in the Build Setting (3 scenes) but found 0 references. It instructed me to check the Console tab for more detail, but there was no information there.

  • Yeah, as a confirmation, I just ran the references search again and I receive the results dialog window:

    Variable search complete
    In total, found 0 references to global variable 'GraphicOptionsData' in the project. Please see the Console window for full details.

    In the Console, comments, warnings, and errors are all at 0.

  • I do not see any option to show realtime values

    It's a global setting, at the top. "Show runtime values?" - sorry, not "realtime".

    Current value: False

    Very strange. What's your Unity version, and what OS are you working on?

    Would it be a hassle to PM me your project as a .zip file? You can leave out the Library folder to help reduce filesize if necessary.

  • Apologies for the delayed response. Unity version is 2022.3.22f1. Operating system is Windows 10.

    I am willing to zip and drop you a copy of the project, but even with the library excluded, and even with only three functional scenes in it, I'll warn you it is pretty large. Part of the point of the project is to test how practical it is to use assets from the Unity Asset Store to create a complete game, so there are about 25 - 30 asset packs imported to it.

    Where would you like it dropped?

  • A Google Drive or Dropbox link would be best - but if the other assets you mention are art (models/sounds etc), then they shouldn't be contributing to the issue. You may want to duplicate the project and remove those assets to reduce the upload time.

  • I did remove a lot of assets, but even so the upload is taking a while.

  • Your patience is appreciated.

  • The upload attempt failed, and I'm sure that is due to the size of the project, even though I deleted lots of the asset packs.

    If you still want to look at the project, I will need to go through it and delete nearly all the other asset packs from it, although that reduces the possibility of pinning down which of those might have caused a conflict in the script, or with the Graphics Options UI variable.

    Do you think it would still be worth pursuing?

  • Excluding the Library folder, what is the size of the cut-down project now?

    I won't insist on the project if it's an inconvenience - but I suspect the error will prevent changes made in the Graphic Options menu from being saved. Is this indeed the case when testing a build?

    Another method we can try is to place some Debug.Log statements on your end, which might be enough to reveal what's going on.

    Try this: open up AC's GVar script and look for the lines that begin with textVal = (case-sensitive) around lines 431, 820, and 947.

    Immediately beneath each of them, copy paste:

    if (Application.IsPlaying && IsGlobalVariable () && id == 0) Debug.Log (label + " value changed to '" + textVal + "', Type: " + type);
    

    Then, what occurences of this get displayed in the Console?

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.