public GetSetGeneric(PropertyInfo info) { Name = info.Name; Info = info; CollectionType = Info.PropertyType.GetInterface("IEnumerable", true) != null; var customAttrs = info.GetCustomAttributes(typeof(Specialist), true); if (customAttrs.Length > 0) { var specialist = (Specialist)customAttrs[0]; Get = (o) => UnitySerializer.Specialists[specialist.Type].Serialize(info.GetValue(o, null)); Set = (o, v) => info.SetValue(o, UnitySerializer.Specialists[specialist.Type].Deserialize(v), null); } else { var getMethod = info.GetGetMethod(true); var setMethod = info.GetSetMethod(true); if (getMethod == null) { Get = (o) => { return(info.GetValue(o, null)); }; Set = (o, v) => { info.SetValue(o, v, null); }; return; } IsStatic = getMethod.IsStatic; Get = (o) => { return(getMethod.FastInvoke(o, null)); //return getMethod.Invoke (o, null); }; Set = (o, v) => { try { setMethod.FastInvoke(o, new[] { v }); } catch (Exception e) { Debug.LogWarning(string.Format("When setting {0} to {1} found {2}:", o != null ? o.ToString() : "null", v != null ? v.ToString() : "null", e.ToString())); } }; } }