I’m using NC 2.3.8, and the method “OnStateEnter” that I implement in my own Monobehaviour is not invoked at all on IOS.
The function GatherDelegates looks like below for IOS platform.
foreach (var mono in agent.gameObject.GetComponents<MonoBehaviour>())
{
……
CallbackEnter += (s)=>{ enterMethod.Invoke(mono, new object[]{s}); };
}
I found that all generated anonymous delegates are referring to the same captured variable, so the delegates would always try to invoke the method in the LAST component on that game object, which is usually not the case.
The fix is simple. Adding a local variable should work.
foreach (var mono in agent.gameObject.GetComponents<MonoBehaviour>())
{
……
var curMono = mono;
CallbackEnter += (s)=>{ enterMethod.Invoke(curMono, new object[]{s}); };