public void OnShowBriefInfo(EventArgs args) { if (args is ShowBriefInfoEA sbi) { string[] messages = sbi.Message.Split('\n'); foreach (var elem in _elements) { elem.RequestTranslation(new Vector2(0, _elementSize.y * messages.Length)); } for (int i = 0; i < messages.Length; ++i) { BriefInfoElement bie = Instantiate(_briefInfoElementPrefab, transform); bie.Initialize(messages[i], GetColorOfMessageType(sbi.Type)); _elements.Add(bie); bie.DisappearingFinished += OnDisappearingFinished; } } else { Log.Instance.WriteException(new InvalidEventArgsException()); } }
private void OnDisappearingFinished(BriefInfoElement bie) { bie.DisappearingFinished -= OnDisappearingFinished; _elements.Remove(bie); Destroy(bie.gameObject); }