Hi,
I'm trying to create a SharedVariable which would hold a value of a generic list so that I can have type safety.
Here's what I tried:
However, I seem to get errors during runtime and even during editing nodes in the Behavior Designer.
What did work was this:
However, I have to cast everything and there isn't really type safety. Is there any way to achieve this?
I need this to pass a list of custom objects (classes) between behavior tree tasks. I am aware there is already a SharedObjectList but most of the time the objects I'm trying to pass aren't Unity Objects, but regular C# ones.
I'm trying to create a SharedVariable which would hold a value of a generic list so that I can have type safety.
Here's what I tried:
C#:
[Serializable]
public class SharedGenericList<T> : SharedVariable<List<T>>
{
public static implicit operator SharedGenericList<T>(List<T> value) { return new SharedGenericList<T> { mValue = value }; }
}
However, I seem to get errors during runtime and even during editing nodes in the Behavior Designer.
What did work was this:
C#:
[Serializable]
public class SharedGenericList : SharedVariable<List<object>>
{
public static implicit operator SharedGenericList(List<object> value) { return new SharedGenericList { mValue = value }; }
}
However, I have to cast everything and there isn't really type safety. Is there any way to achieve this?
I need this to pass a list of custom objects (classes) between behavior tree tasks. I am aware there is already a SharedObjectList but most of the time the objects I'm trying to pass aren't Unity Objects, but regular C# ones.