Esempio n. 1
0
        public virtual void Load(StringReaderEx str, object obj)
        {
            Type t = obj.GetType();

            var fields = t.GetFields(getFieldFlags).Where(f => f.GetCustomAttributes(typeof(StoreThis), true).Length > 0).ToArray();

            int len = str.ReadLineInt();

            if (fields.Length != len)
            {
                throw new UnityException("Incorrect save file");
            }

            for (int i = 0; i < len; i++)
            {
                string fieldName = str.ReadLine();
                string fieldData = str.ReadLine();

                //Debug.Log("    > Loading field "+fieldName);
                FieldInfo finfo = fields.Where(f => f.Name == fieldName).First();
                if (finfo == null)
                {
                    continue;
                }
                StoreBase.LoadField(finfo, obj, fieldData);
            }
        }