File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 1- using System . Collections ;
2- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
32using UnityEngine ;
3+ using UnityEngine . Events ;
44
55namespace Gameframe . ScriptableObjects . RuntimeSets
66{
77 public class RuntimeSet < T > : ScriptableObject
88 {
9+ public class RuntimeSetChangeEvent : UnityEvent < T > { }
910
10- List < T > items = new List < T > ( ) ;
11- public List < T > Items => items ;
11+ private readonly List < T > _items = new List < T > ( ) ;
12+ public IReadOnlyList < T > Items => _items ;
13+
14+ public RuntimeSetChangeEvent OnAdded { get ; } = new RuntimeSetChangeEvent ( ) ;
15+ public RuntimeSetChangeEvent OnRemoved { get ; } = new RuntimeSetChangeEvent ( ) ;
1216
1317 public void Add ( T t )
1418 {
15- items . Add ( t ) ;
19+ _items . Add ( t ) ;
20+ OnAdded . Invoke ( t ) ;
1621 }
1722
1823 public void Remove ( T t )
1924 {
20- items . Remove ( t ) ;
25+ _items . Remove ( t ) ;
26+ OnRemoved . Invoke ( t ) ;
2127 }
22-
2328 }
24- }
29+ }
You can’t perform that action at this time.
0 commit comments