public void deserialize(ByteBuffer buffer) { id = buffer.ReadLong(); type = buffer.ReadByte(); title = buffer.ReadString(); time = buffer.ReadString(); byte len = buffer.ReadByte(); for (int i = 0; i < len; i++) { TimeContent content = new TimeContent(); content.deserialize(buffer); contents.Add(content); } }
void goToDetail(TimeLine timeLine) { needshow[0].transform.FindChild("list").gameObject.SetActive(false); Transform detail_trans = needshow[0].transform.FindChild("detail"); detail_trans.gameObject.SetActive(true); callback = new EventDelegate(backFromDetail); if (detail_container == null) { detail_container = detail_trans.FindChild("body").FindChild("container"); } MyUtilTools.clearChild(detail_container); detail_container.parent.GetComponent <UIPanel>().clipOffset = Vector2.zero; detail_container.parent.localPosition = new Vector3(0, 0, 0); GameObject newObj = new GameObject(); GameObject title_obj = NGUITools.AddChild(detail_container.gameObject, newObj); title_obj.transform.localPosition = new Vector3(0, 520, 0); title_obj.name = "title"; UILabel title_label = title_obj.AddComponent <UILabel>(); title_label.trueTypeFont = labelFont; title_label.fontSize = 50; title_label.text = timeLine.title; title_label.width = 800; title_label.height = 60; title_label.spacingX = 5; title_label.spacingY = 5; title_label.maxLineCount = 100; title_label.color = Color.black; title_label.depth = 2; float starty = 450; for (int i = 0; i < timeLine.contents.Count; i++) { GameObject sun = null; TimeContent content = timeLine.contents[i]; int height = 0; float offset = 0; if (content.type == 0) { sun = NGUITools.AddChild(detail_container.gameObject, title_obj); sun.name = "content" + i; UILabel sun_label = sun.GetComponent <UILabel>(); sun_label.fontSize = 40; sun_label.width = 750; sun_label.height = 10000; sun_label.text = content.str_value; int row = MyUtilTools.computeRow(sun_label); int total = row * (sun_label.fontSize + title_label.spacingY); sun_label.height = total; height = total; offset = total / 2; } else { sun = NGUITools.AddChild(detail_container.gameObject, newObj); sun.name = "content" + i; UITexture texture = sun.AddComponent <UITexture>(); texture.width = 512; texture.height = 512; JustRun.Instance.loadPic(content.str_value, texture); height = texture.height + 20; offset = texture.height / 2; } starty -= height; sun.transform.localPosition = new Vector3(0, starty + offset, 0); } Destroy(newObj); }