internal static IEnumerable <FieldInfo> GetAllSerializableFields(System.Type tp)
        {
            var nonSerializedAttrib = typeof(System.NonSerializedAttribute);
            var serializedAttrib    = typeof(UnityEngine.SerializeField);

            while (tp != null)
            {
                foreach (var fi in tp.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
                {
                    if (UnityDataFormatter.IsUnitySerializable(fi.FieldType))
                    {
                        if (fi.IsPublic)
                        {
                            if (!System.Attribute.IsDefined(fi, nonSerializedAttrib))
                            {
                                yield return(fi);
                            }
                        }
                        else
                        {
                            if (System.Attribute.IsDefined(fi, serializedAttrib))
                            {
                                yield return(fi);
                            }
                        }
                    }
                }
                tp = tp.BaseType;
            }
        }
 ISerializationSurrogate ISurrogateSelector.GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
 {
     if (UnityDataFormatter.IsUnitySerializable(type))
     {
         selector = this;
         return(this);
     }
     else
     {
         selector = null;
         return(null);
     }
 }