public void ReadClass(object cls) { var cn = IOHelp.ReadString(); var np = IOHelp.ReadInt(); foreach (var prop in cls.GetType().GetProperties()) { var pn = IOHelp.ReadString(); int pt = IOHelp.ReadInt(); switch (pt) { case -1: prop.SetValue(cls, null); break; case 0: prop.SetValue(cls, IOHelp.ReadString()); break; case 1: prop.SetValue(cls, IOHelp.ReadInt()); break; case 2: prop.SetValue(cls, IOHelp.ReadFloat()); break; case 3: prop.SetValue(cls, IOHelp.ReadDouble()); break; case 4: prop.SetValue(cls, IOHelp.ReadTexture2D()); break; case 5: prop.SetValue(cls, IOHelp.ReadBool()); break; case 6: prop.SetValue(cls, IOHelp.ReadVec3()); break; case 7: prop.SetValue(cls, IOHelp.ReadVec4()); break; case 8: prop.SetValue(cls, IOHelp.ReadMatrix()); break; case 9: dynamic nl = prop.GetValue(cls); nl.Clear(); int ec = IOHelp.ReadInt(); for (int i = 0; i < ec; i++) { } break; } } }