ChatBarItem.cs 938 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class ChatBarItem : ItemRenderer
  5. {
  6. public Text nameTxt;
  7. public Text contentTxt;
  8. public Text timeTxt;
  9. void Awake()
  10. {
  11. }
  12. public override object data {
  13. get {
  14. return base.data;
  15. }
  16. set {
  17. base.data = value;
  18. if(value is ChatMsg)
  19. {
  20. ChatMsg chatMsg = value as ChatMsg;
  21. nameTxt.text = UserCache.GetNick (chatMsg.sender);
  22. contentTxt.text = chatMsg.content;
  23. timeTxt.text = chatMsg.dateTime.ToString ();
  24. }
  25. else if(value is Follower)
  26. {
  27. Follower follower = value as Follower;
  28. nameTxt.text = UserCache.GetNick (follower.userId);
  29. contentTxt.text = follower.GetLastMsg ();
  30. timeTxt.text = follower.GetLastMsgTime ();
  31. }
  32. }
  33. }
  34. public void OnClick()
  35. {
  36. if (data == null)
  37. return;
  38. if(data is Follower)
  39. {
  40. Follower follower = data as Follower;
  41. ChatPanel.ShowChat (follower.userId);
  42. }
  43. }
  44. }