public virtual void AddEntry(ChatEntry.Model chatEntryModel, bool setScrollPositionToBottom = false) { var chatEntryGO = Instantiate(Resources.Load(ENTRY_PATH) as GameObject, chatEntriesContainer); ChatEntry chatEntry = chatEntryGO.GetComponent <ChatEntry>(); if (enableFadeoutMode && EntryIsVisible(chatEntry)) { chatEntry.SetFadeout(true); } else { chatEntry.SetFadeout(false); } chatEntry.Populate(chatEntryModel); if (chatEntryModel.messageType == ChatMessage.Type.PRIVATE) { chatEntry.OnPress += OnPressPrivateMessage; } chatEntry.OnTriggerHover += OnMessageTriggerHover; chatEntry.OnCancelHover += OnMessageCancelHover; entries.Add(chatEntry); SortEntries(); Utils.ForceUpdateLayout(transform as RectTransform, delayed: false); if (setScrollPositionToBottom) { scrollRect.verticalNormalizedPosition = 0; } }
public void SetFadeoutMode(bool enabled) { enableFadeoutMode = enabled; for (int i = 0; i < entries.Count; i++) { ChatEntry entry = entries[i]; if (enabled) { entry.SetFadeout(EntryIsVisible(entry)); } else { entry.SetFadeout(false); } } }
public override void AddEntry(ChatEntry.Model chatEntryModel, bool setScrollPositionToBottom = false) { AddSeparatorEntryIfNeeded(chatEntryModel); var chatEntryGO = Instantiate(Resources.Load(chatEntryModel.subType == ChatEntry.Model.SubType.PRIVATE_TO ? ENTRY_PATH_SENT : ENTRY_PATH_RECEIVED) as GameObject, chatEntriesContainer); ChatEntry chatEntry = chatEntryGO.GetComponent <ChatEntry>(); chatEntry.SetFadeout(false); chatEntry.Populate(chatEntryModel); chatEntry.OnTriggerHover += OnMessageTriggerHover; chatEntry.OnCancelHover += OnMessageCancelHover; entries.Add(chatEntry); Utils.ForceUpdateLayout(transform as RectTransform, delayed: false); if (setScrollPositionToBottom) { scrollRect.verticalNormalizedPosition = 0; } }