/// <summary> /// Handle send message event. /// </summary> public void OnSendMessage() { if (ValidateMessage()) { InboxMetaData data = InboxMetaData.Load(); data.AddInboxMessage("Player", recipientIdInput.value, titleInput.value, contentInput.value); EventManager.GetInstance().ExecuteEvent <EventNewMessage>(new EventNewMessage()); recipientIdInput.value = ""; titleInput.value = ""; contentInput.value = ""; _navigationController.CloseNavigationController(); } }
/// <summary> /// Handle unexpand event. /// </summary> public void OnUnexpand() { if (isShowMessage) { isShowMessage = !isShowMessage; messageScrollview.gameObject.SetActive(false); } if (!isRead) { InboxMetaData data = InboxMetaData.Load(); data.MarkRead(messageId); notifySprite.enabled = false; isRead = true; } }
/// <summary> /// Updates the inbox. /// </summary> void UpdateInbox() { if (table.transform.childCount > 0) { List <Transform> childs = new List <Transform>(); for (int i = 0; i < table.transform.childCount; i++) { childs.Add(table.transform.GetChild(i)); } for (int i = 0; i < childs.Count; i++) { childs[i].parent = null; NGUITools.Destroy(childs[i].gameObject); } } InboxMetaData data = InboxMetaData.Load(); InboxMessage[] messages = data.GetAllMessages(); for (int i = 0; i < messages.Length; i++) { GameObject newMessage = NGUITools.AddChild(table.gameObject, inboxItemPrefab); InboxItem display = newMessage.GetComponent <InboxItem>(); display.SetInboxItemInfo(messages[i]); } table.Reposition(); scrollview.ResetPosition(); }