@@ -68,30 +68,39 @@ public override string ToString()
6868
6969 #region Set/Remove
7070
71- private bool HasConsumer ( )
72- {
73- return OnValueChanged . GetInvocationList ( ) . Length > 0 ;
74- }
75-
7671 public void SuppressEagerUpdatesThisFrame ( )
7772 {
7873 SuppressEagerUpdate = true ;
7974 MaterialPropertyManager . Instance ? . ScheduleLateUpdate ( this ) ;
8075 }
8176
77+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
78+ private void FireOnEntriesChanged ( )
79+ {
80+ if ( ! SuppressEagerUpdate ) {
81+ OnEntriesChanged ? . Invoke ( this ) ;
82+ } else {
83+ NeedsEntriesUpdate = true ;
84+ }
85+ }
86+
87+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
88+ private void FireOnValueChanged ( int ? id )
89+ {
90+ if ( ! SuppressEagerUpdate ) {
91+ OnValueChanged ? . Invoke ( this , id ) ;
92+ } else {
93+ NeedsValueUpdate = true ;
94+ }
95+ }
96+
8297 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
8398 private void _internalSet < T , TProp > ( int id , T value ) where TProp : Prop < T >
8499 {
85100 if ( props . TryGetValue ( id , out var prop ) ) {
86101 if ( prop is TProp typedProp ) {
87102 if ( ! typedProp . UpdateIfChanged ( value ) ) return ;
88-
89- if ( ! SuppressEagerUpdate ) {
90- OnValueChanged ? . Invoke ( this , id ) ;
91- } else {
92- NeedsValueUpdate = true ;
93- }
94-
103+ FireOnValueChanged ( id ) ;
95104 return ;
96105 }
97106
@@ -100,12 +109,7 @@ private void _internalSet<T, TProp>(int id, T value) where TProp : Prop<T>
100109 }
101110
102111 props [ id ] = ( TProp ) Activator . CreateInstance ( typeof ( TProp ) , value ) ;
103-
104- if ( ! SuppressEagerUpdate ) {
105- OnEntriesChanged ? . Invoke ( this ) ;
106- } else {
107- NeedsEntriesUpdate = true ;
108- }
112+ FireOnEntriesChanged ( ) ;
109113 }
110114
111115 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -117,13 +121,25 @@ private void _internalSet<T, TProp>(int id, T value) where TProp : Prop<T>
117121 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
118122 public void SetInt ( int id , int value ) => _internalSet < int , PropInt > ( id , value ) ;
119123
124+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
120125 public void SetTexture ( int id , Texture value ) => _internalSet < Texture , PropTexture > ( id , value ) ;
126+
127+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
121128 public void SetVector ( int id , Vector4 value ) => _internalSet < Vector4 , PropVector > ( id , value ) ;
122129
130+ public bool Remove ( int id )
131+ {
132+ var removed = props . Remove ( id ) ;
133+ if ( ! removed ) return false ;
134+ FireOnEntriesChanged ( ) ;
135+ return true ;
136+ }
137+
123138 #endregion
124139
125140 #region Has
126141
142+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
127143 private bool _internalHas < T > ( int id ) => props . TryGetValue ( id , out var prop ) && prop is Prop < T > ;
128144
129145 public bool HasColor ( int id ) => _internalHas < Color > ( id ) ;
0 commit comments