Skip to content

Commit

Permalink
fix: added destroy notice item support
Browse files Browse the repository at this point in the history
  • Loading branch information
Iam1337 committed Mar 19, 2022
1 parent 22407d9 commit 788ba29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Assets/extDebug.UGUI/Scripts/Notifications/NoticeItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public float Alpha

[NonSerialized]
public Vector2 Velocity;

[NonSerialized]
public DNNotice Notice;

#endregion

Expand All @@ -65,5 +68,15 @@ public float Alpha
private TextMeshPro _label_TextMeshPro;

#endregion

#region Unity Methods

private void OnDestroy()
{
if (Notice.Data is NoticeItem item && item == this)
Notice.Data = null;
}

#endregion
}
}
2 changes: 1 addition & 1 deletion Assets/extDebug.UGUI/Scripts/Notifications/NoticeRender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public NoticeRender(RectTransform noticeAnchor, NoticeItem noticePrefab, RenderT
void IDNRender.SetupNotice(DNNotice notice, float currentHeight)
{
var noticeData = Object.Instantiate(_noticePrefab, _noticeAnchor);
noticeData.Notice = notice;
noticeData.Text = notice.Text;

if (_type == RenderType.Default)
Expand Down Expand Up @@ -103,7 +104,6 @@ void IDNRender.Repaint(DNNotice notice, float timeLeft, ref float currentHeight)
{
noticeData.Alpha -= Time.unscaledDeltaTime * 4.5f;
}

}

// Calculate new positions
Expand Down

0 comments on commit 788ba29

Please sign in to comment.