[Bug] Null Reference Exception caused by serialized list parameter in State Behavior

Cheo

Active member
Hello, this issue might be a bit of a niche case as I don't recall ever needing that before, but basically when using a State Behavior that contains a serialized list as a parameter, we get an error when UCC tries to initialize the states and their presets. To give a clear example, try adding this simple script to an empty object in a scene :

C#:
using Opsive.Shared.StateSystem;
using System.Collections.Generic;
using UnityEngine;

public class StateBehaviorTest : StateBehavior
{
    [SerializeField] protected List<int> m_IntList;
    public List<int> IntList { get { return m_IntList; } set { m_IntList = value; } }

}

And then, without even bothering to create an actual preset, just hit play and you should get this error :

Edit : Goddammit what the hell is going on, I can't share the rest ! I'll send Justin a mail if I still can't, but you'll be able to see the error yourselves if you try it out.
And to be totally honest I don't even think I actually needed my list to be modifiable by the state system when I tried that, but still there is a void called UpdateIList so I'm assuming this is supposed to be possible just like for other types of parameters. Hope this can be taken a look at, thanks in advance.
 
Last edited:
Thanks for the report. It's having a problem casting source to IList<T>. You can fix this by changing the following within Preset.UpdateIList:

Code:
                    var sourceList = source as IList<T>;
                    var destinationList = destination as IList<T>;
to:
Code:
                    var sourceList = source as IList;
                    var destinationList = destination as IList;
 
Top