From dd0be219cf54cd2b19627f2dd81345c17974d886 Mon Sep 17 00:00:00 2001
From: Eric Heine <erheine@nps.edu>
Date: Tue, 26 Oct 2021 10:28:24 -0700
Subject: [PATCH] Added a virtual function to do any cleanup necessary when an
 item is removed from a DynamicList.

---
 Sane Eric's UI/DynamicList.cs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Sane Eric's UI/DynamicList.cs b/Sane Eric's UI/DynamicList.cs
index acb1a48..9847112 100644
--- a/Sane Eric's UI/DynamicList.cs	
+++ b/Sane Eric's UI/DynamicList.cs	
@@ -48,6 +48,7 @@ namespace Shared.SEUI {
     // Remove the given item from the list (if it is in the list)
     public void RemoveItem(TValueType item) {
       if (listItems.ContainsKey(item)) {
+        OnItemRemoved(item, listItems[item]);
         Destroy(listItems[item].gameObject);
         listItems.Remove(item);
       }
@@ -55,6 +56,10 @@ namespace Shared.SEUI {
 
     // --------------------------------------------------------------------------
     // Implement if the list needs to do something to the DynamicListItem after it has been added to the list
-    protected virtual void OnItemAdded(TValueType item, TDynamicListItem itemUI) { }
+    protected virtual void OnItemAdded(TValueType item, TDynamicListItem itemUI) {}
+
+    // --------------------------------------------------------------------------
+    // Implement if the list needs to do something to the DynamicListItem after it has been removed from the list
+    protected virtual void OnItemRemoved(TValueType item, TDynamicListItem itemUI) {}
   }
 }
-- 
GitLab