public void Vector3Test() { ST_Vector3 st = new ST_Vector3(1.123456f, 2.123456f, 3.123456f); LBObject lb = new LBObject(); lb.SetFloat("x", st.x); lb.SetFloat("y", st.y); lb.SetFloat("z", st.z); ClassTest("Vector3", st, lb); }
public void NestedTypeTest() { // Class ST_PlayerInfo playerInfo = new ST_PlayerInfo(); playerInfo.id = 100001; playerInfo.nickname = "Zero"; playerInfo.gender = 1; playerInfo.isVip = true; playerInfo.lv = 999; playerInfo.hp = 99999; playerInfo.mp = 99999; playerInfo.exp = 99999999; playerInfo.speed = 2.5f; ST_Vector3 position = new ST_Vector3(1.123456f, 2.123456f, 3.123456f); ST_Color color = new ST_Color(1 / 255f, 2 / 255f, 3 / 255f); ST_NestedType st = new ST_NestedType(); st.playerInfo = playerInfo; st.position = position; st.color = color; // LBObject LBObject lb = new LBObject(); LBObject lbPlayerInfo = new LBObject(); LBObject lbPosition = new LBObject(); LBObject lbColor = new LBObject(); lbPlayerInfo.SetUInt("id", playerInfo.id); lbPlayerInfo.SetString("nickname", playerInfo.nickname); lbPlayerInfo.SetByte("gender", playerInfo.gender); lbPlayerInfo.SetBool("isVip", playerInfo.isVip); lbPlayerInfo.SetInt("lv", playerInfo.lv); lbPlayerInfo.SetInt("hp", playerInfo.hp); lbPlayerInfo.SetInt("mp", playerInfo.mp); lbPlayerInfo.SetInt("exp", playerInfo.exp); lbPlayerInfo.SetFloat("speed", playerInfo.speed); lbPosition.SetFloat("x", position.x); lbPosition.SetFloat("y", position.y); lbPosition.SetFloat("z", position.z); lbColor.SetFloat("r", color.r); lbColor.SetFloat("g", color.g); lbColor.SetFloat("b", color.b); lb.SetObject("playerInfo", lbPlayerInfo); lb.SetObject("position", lbPosition); lb.SetObject("color", lbColor); ClassTest("NestedType", st, lb); /* * // Convert * string structName = "NestedType"; * byte[] bytes = LB.ToBytes(structName, st); * //print("==================== NestedType Test ===================="); * * // Parse * ST_NestedType vo = LB.ToObject<ST_NestedType>(structName, bytes); * * // Print * //print("LB ByteSize: " + bytes.Length); * ST_PlayerInfo pvo = vo.playerInfo; * //print("vo.player.id: " + pvo.id); * //print("vo.player.nickname: " + pvo.nickname); * //print("vo.player.gender: " + pvo.gender); * //print("vo.player.isVip: " + pvo.isVip); * //print("vo.player.lv: " + pvo.lv); * //print("vo.player.hp: " + pvo.hp); * //print("vo.player.mp: " + pvo.mp); * //print("vo.player.exp: " + pvo.exp); * //print("vo.player.speed: " + pvo.speed); * PrintVector3("vo.position: ", vo.position); * PrintColor("vo.color: ", vo.color); */ }
private void PrintVector3(string prefix, ST_Vector3 vector3) { //print(prefix + "(" + vector3.x + ", " + vector3.y + ", " + vector3.z + ")"); }