public void AddChat(ChatMessage ChatMessageText) { string ChatText = ChatMessageText.ExportText(); GameObject chatItem = Instantiate(ChatItemPrefab); chatItem.GetComponent <ChatItem>().SetChatText(ChatText); chatItem.transform.SetParent(Content, false); ChatItems.Add(chatItem); }
public void ChatMessageSendPublic(string chatMessageString) { string uniqueID = mDatabaseRef.Child("PublicChat").Push().Key; ChatMessage msg = new ChatMessage(currentUser.userNickName, "PublicChat", chatMessageString); mDatabaseRef.Child("PublicChat").Child(uniqueID).SetRawJsonValueAsync(JsonUtility.ToJson(msg)); Debug.Log("uniqueID" + uniqueID); Debug.Log("message send" + msg.ExportText()); }
public bool NewItemAdded = false;// trigger flag void HandleChildAdded(object sender, ChildChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(args.Snapshot.GetRawJsonValue()); ChatMessage msg = new ChatMessage(values["senderID"], values["receiverID"], values["messageText"]); MessageList.Add(msg); Debug.Log("new " + msg.ExportText()); NewItemAdded = true; }