Beispiel #1
0
        /// <summary>
        /// Display ChatLine.
        /// </summary>
        /// <param name="item">Item.</param>
        public void SetData(ChatLine item)
        {
            UserName.text = item.UserName;
            Message.text  = item.Message;
            Time.text     = item.Time.ToString("[HH:mm:ss]");

            // change colors depend of origin
            if (item.Type == ChatLineType.System)
            {
                UserName.color = Color.red;
                Message.color  = Color.red;
            }
            else
            {
                UserName.color = Color.white;
                Message.color  = Color.white;
            }

            Utilites.UpdateLayout(GetComponent <LayoutGroup>());
        }
Beispiel #2
0
        /// <summary>
        /// Display ChatLine.
        /// </summary>
        /// <param name="item">Item.</param>
        public void SetData(ChatLine item)
        {
            Item = item;

            UserName.text = item.UserName;
            Message.text  = item.Message;
            Time.text     = item.Time.ToString("[HH:mm:ss]");

            if (Image != null)
            {
                Image.gameObject.SetActive(item.Image != null);
                Image.sprite = item.Image;
            }

            if (Audio != null)
            {
                Audio.gameObject.SetActive(item.Audio != null);
                Audio.SetAudioClip(item.Audio);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        public void SendMessage()
        {
            if (string.IsNullOrEmpty(UserName.text.Trim()))
            {
                return;
            }

            if ((string.IsNullOrEmpty(Message.text.Trim())) && !AttachImage.IsOn && !AttachAudio.IsOn)
            {
                return;
            }

            // add new message to chat
            var line = new ChatLine()
            {
                UserName = UserName.text,
                Message  = Message.text,
                Time     = DateTime.Now,
                Type     = Type.IsOn ? ChatLineType.Outgoing : ChatLineType.Incoming,
            };

            if (AttachImage.IsOn)
            {
                line.Image = TestImage;
            }
            if (AttachAudio.IsOn)
            {
                line.Audio = TestAudio;
            }
            Chat.DataSource.Add(line);

            Message.text = "";

            // scroll to end
            Chat.ScrollRect.verticalNormalizedPosition = 0f;
        }
 /// <summary>
 /// Display ChatLine.
 /// </summary>
 /// <param name="item">Item.</param>
 public void SetData(ChatLine item)
 {
     UserName.text = item.UserName;
     Message.text  = item.Message;
     Utilites.UpdateLayout(GetComponent <LayoutGroup>());
 }