diff --git a/Utilities/FastInvoke.cs b/Utilities/FastInvoke.cs index 8cd208c..c989b28 100644 --- a/Utilities/FastInvoke.cs +++ b/Utilities/FastInvoke.cs @@ -10,14 +10,14 @@ namespace Svelto.Utilities public static class FastInvoke where T : class { #if ENABLE_IL2CPP - public static Action MakeSetter(FieldInfo field) where CastedType:class + public static CastedAction MakeSetter(FieldInfo field) where CastedType:class { - if (field.FieldType.IsInterface == true && field.FieldType.IsValueType == false) + if (field.FieldType.IsInterfaceEx() == true && field.FieldType.IsValueTypeEx() == false) { - return new Action((target, value) => field.SetValue(target, value)); + return new CastedAction(field.SetValue); } - throw new ArgumentException("Svelto.ECS unsupported EntityView field (must be an interface and a class)"); + throw new ArgumentException("Svelto.ECS unsupported field (must be an interface and a class)"); } #elif !NETFX_CORE public static CastedAction MakeSetter(FieldInfo field) where CastedType:class @@ -38,7 +38,7 @@ namespace Svelto.Utilities return new CastedAction(del); } - throw new ArgumentException("Svelto.ECS unsupported EntityView field (must be an interface and a class)"); + throw new ArgumentException("Svelto.ECS unsupported field (must be an interface and a class)"); } #else public static CastedAction MakeSetter(FieldInfo field) where CastedType:class @@ -59,7 +59,7 @@ namespace Svelto.Utilities return new CastedAction(setter); } - throw new ArgumentException("Svelto.ECS unsupported EntityView field (must be an interface and a class)"); + throw new ArgumentException("Svelto.ECS unsupported field (must be an interface and a class)"); } #endif } @@ -78,6 +78,11 @@ namespace Svelto.Utilities this.setter = (Action)setter; } + public CastedAction(Action setter) + { + this.setter = setter; + } + override public void Call(W target, object value) { setter(target as T, value);