I experienced the issue, that when I try to iterate over a IList<Vector3> with a Behaviour Tree, the Iterator Decorator breaks the Type of the variable assigned to ‘current’.
if ( current.varType != argType ) {
current.SetType(argType);
}
}}
The problem is, that the method GetEnumerableElementType() in its current state returns null for a generic interface.
The following code then changes the value of the ‘current’ variable to null.
When looking at the method, I found that the code for detecting the generic type (in my case Vector3) in an interface is commented out.
Maybe it would make sense to enable the generic interface type detection for the Iterator Decorator.
Also, I think the secretive change of a variable type to null maybe should be avoided.
Hmm. Even with that piece of code comented out, if I run a Debug.Log(typeof(IList<Vector3>).GetEnumerableElementType());, it will correctly return typeof(Vector3). Maybe the issue lies somewhere else? What version of Unity are you using and what are the scripting backened, compatibility level and version in Unity Player Settings?
I checked the output of Debug.Log(typeof(IList).GetEnumerableElementType()); and I get the same result as you: typeof(Vector3)
Then I created a Test class public class Test : IList and found, that typeof(Test).GetEnumerableElementType() returns null. The reason for this behaviour is, that type.RTIsGenericType() in GetEnumerableElementType returns false for typeof(Test) which has no generic arguments.
Uncommenting the commented code in GetEnumerableElementType results in typeof(Test).GetEnumerableElementType()returning typeof(Vector3).
Unity: 2018.3.6f1
Scripting Runtime Version: .Net 4.x Equivalent
Scripting Backend: Mono
Api Compatibility Level .Net Standard 2.0
Thank you for your input and clarification. That makes sense 🙂 I think that uncommenting that code should be fine. I will need to run some check ups to see everything still working correctly in all respects and if so, I will uncomment those lines of code for the next version as well, and try to fix any potential errors there could apear due to that (if any).
So, for the time being, I suggest you uncomment these lines of code on your side since that should not create any issues as far as I can tell right now and achieves what you are after as well 🙂