Forum rules - please read before posting.

IndexOutOfRangeException... SaveSystem.AssignMenuElementVisibility...

edited July 2014 in Technical Q&A

I get an error when I load a saved game:

IndexOutOfRangeException: Array index is out of range.

SaveSystem.AssignMenuElementVisibility (System.Collections.Generic.List`1 menus, System.String menuElementVisibilityData) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1299)

SaveSystem.ReturnMainData () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:929)

SaveSystem.OnLevelWasLoaded () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:247)


This is a new error, I believe it started showing up after I shortened the default Options menu. I deleted the “Speech volume,” “Language” and “Subtitles” options. “Options elements” now reads:

0: TitleLabel

2: MusicSlider

3: SFXSlider

6: BackButton

Could this be what’s causing this error? If so, is there a way for me to fix it? Could something else be causing this error?


Thanks again!

Ben

Comments

  • If the Menu Manager has a different number of menus / elements than it did when the loaded game was created, then the saved game will no longer be compatible.  When you make a new save and re-load that, does the problem persist?
  • I figured as much, so I have been testing this with new saves only. I get some additional errors if I save and load from within the same scene (any scene, just must save/load within same scene.)

    IndexOutOfRangeException: Array index is out of range.

    SaveSystem.AssignMenuElementVisibility (System.Collections.Generic.List`1 menus, System.String menuElementVisibilityData) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1299)

    SaveSystem.ReturnMainData () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:929)

    SaveSystem.OnLevelWasLoaded () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:247)

    SaveSystem.LoadSaveGame (Int32 slot) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:170)

    SaveSystem.LoadGame (Int32 slot) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:75)

    AC.PlayerMenus.CheckClick (AC.Menu _menu, AC.MenuElement _element, Int32 _slot, MouseState _mouseState) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:877)

    AC.PlayerMenus.UpdateElements (AC.Menu menu) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:720)

    AC.PlayerMenus.UpdateAllMenus () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:775)

    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:119)

  • It looks like I found the answer! I added a Debug.Log(menuElementVisibilityData); @ SaveSystem.cs line 1275 which produced the following output:
    12:0=True+1=True+2=True+3=True+4=True|0:0=True+2=True+3=True+6=True|1:0=True+1=True+3=True|2:0=True+1=True+3=True|3:1=True+0=True+2=True|4:0=True|5:0=True+1=True|6:1=True+3=True+0=True+2=True|9:0=True+1=True|8:1=True+2=True+0=True+3=True+4=True+5=True+6=True+7=True+8=True+9=True|10:0=True+1=True+2=True+3=True+4=True+5=True+6=True+7=True+8=True+9=True|11:0=True|7:0=True+1=True+3=True+4=True|13:0=True+2=True+3=True+6=True|14:0=True+1=True+3=True|15:

    This pointed me to Menu 15, which I had set up to display the game logo. I only used a background texture to display the logo- without any elements, since I didn't think I needed any and it worked just fine without. After adding a blank “Label,” and re-saving, the error went away. So it looks like every Menu needs an element, even if it is blank. 

    Hope this helps troubleshoot future user errors!

  • If that's the case, then that's a bug indeed.  Glad you found a workaround, but I'll see to it that's fixed next time.
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.