I defined a Class called Game State and put another class in it called Activity State.
I have two graph variables:
- One is currentActivity, of type Activity State.
- Another is listOfActivities, which is a List of Activity States.
I want to look inside of the listOfActivities and get the index number of the Activity State that matches currentActivity. (I know for sure that the item is in the list - just want the index number of it.)
I am getting an error:
InvalidConversionException: Cannot convert from ‘System.Collections.Generic.List`1[ActivityState]’ to ‘Unity.VisualScripting.AotList’.
From what I understand, the Index Of node can not work on generic lists like Activity State. It can only work on AOT lists.
I have tried two different paths:
- Write a custom node that can get an Index Of for a generic list, so I can plug in my List of Activity States directly into that.
- Write a custom node that can convert my generic List of Activity States into an AOT list.
I have failed at both of these attempts. There is a third hacky option:
- I could hack a subgraph which just iterates through every item on the list and looks for a match.
I guess I could do #3, but I feel like there must be a simpler way to access the Index Of an item that I know to be on a generic list.
Does anyone have advice on how to proceed?