Forum rules - please read before posting.

PopUp Switch: ArgumentOutOfRangeException

Hey @ChrisIceBox,

I might have found a bug with popup switches. When I enter my scene and the popup variable is set to a state that has not connection in the output, I get the following exception:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at :0)
AC.ActionList.EndAction (AC.Action action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:551)
AC.ActionList+d__47.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:540)
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:412)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:617)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:576)
AC.d__47:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:540)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Might be solved by just doing (ActionList.cs, 546):

        private void EndAction (Action action)
        {
            action.isRunning = false;

            int endIndex = action.GetNextOutputIndex ();

            if (endIndex < 0 && endIndex >= action.endings.Count)
                return;
...

But maybe it's not that simple.

Cheers!

Comments

  • Is this a case of the PopUp being updated without "viewing" the ActionList that references it?

    What's your AC version? This may already be fixed.

  • It's true, I'm not on the latest version, I'm using v1.81.2, I will update soon. If it is already fixed, sorry for the disturbance and thanks for the reply!

  • I don't recall a fix for this in the releases since - I'll look into it, thanks for the report.

  • It might occur in the following scenario: an actionlist contains a popup switch and after adding a new popup state, if the variable is set to that new state and the switch has no connection at that output, the exception is being thrown. I haven't tried it out yet, but it feels like this is when it happens.

  • Looking at the ActionList code in the newest version is making me think two things: it might be already fixed by checking the index boundries, but I was wondering if it should be "endIndex >= action.endings.Count":

    ActionEnd actionEnd = (endIndex < 0 || endIndex > action.endings.Count) ? Action.GenerateStopActionEnd () : action.endings[endIndex];

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.