public void Encode(XLua.LuaTable luaTable, BinaryWriter stream) { var dictionary = luaTable.Cast <Dictionary <String, object> >(); foreach (var v in _attrs) { try { if (v.type.Equals(s_sString)) { doSerialize(stream, (String)dictionary[v.name]); } else if (v.type.Equals(s_sInt32)) { doSerialize(stream, Convert.ToInt32(dictionary[v.name])); } else if (v.type.Equals(s_sUint32)) { doSerialize(stream, Convert.ToUInt32(dictionary[v.name])); } else if (v.type.Equals(s_sEnum)) { doSerialize(stream, Convert.ToInt32(dictionary[v.name])); } else if (v.type.Equals(s_sUint8)) { doSerialize(stream, Convert.ToByte(dictionary[v.name])); } else if (v.type.Equals(s_sUint16)) { doSerialize(stream, Convert.ToUInt16(dictionary[v.name])); } else if (v.type.Equals(s_sUint64)) { doSerialize(stream, Convert.ToUInt64(dictionary[v.name])); } else if (v.type.Equals(s_sInt8)) { doSerialize(stream, Convert.ToSByte(dictionary[v.name])); } else if (v.type.Equals(s_sInt16)) { doSerialize(stream, Convert.ToInt16(dictionary[v.name])); } else if (v.type.Equals(s_sInt64)) { doSerialize(stream, Convert.ToInt64(dictionary[v.name])); } else if (v.type.Equals(s_sDouble)) { doSerialize(stream, Convert.ToDouble(dictionary[v.name])); } else if (v.type.Equals(s_sFloat)) { doSerialize(stream, Convert.ToSingle(dictionary[v.name])); } else if (v.type.Equals(s_sBool)) { doSerialize(stream, Convert.ToBoolean(dictionary[v.name])); } else { XLua.LuaTable table = (XLua.LuaTable)dictionary[v.name]; table.Get <String, MessageLua>(s_sSelf).Encode(table, stream); } } catch (Exception e) { UnityEngine.Debug.LogException(e); } } }