@@ -68,30 +68,39 @@ public override string ToString()
68
68
69
69
#region Set/Remove
70
70
71
- private bool HasConsumer ( )
72
- {
73
- return OnValueChanged . GetInvocationList ( ) . Length > 0 ;
74
- }
75
-
76
71
public void SuppressEagerUpdatesThisFrame ( )
77
72
{
78
73
SuppressEagerUpdate = true ;
79
74
MaterialPropertyManager . Instance ? . ScheduleLateUpdate ( this ) ;
80
75
}
81
76
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
+
82
97
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
83
98
private void _internalSet < T , TProp > ( int id , T value ) where TProp : Prop < T >
84
99
{
85
100
if ( props . TryGetValue ( id , out var prop ) ) {
86
101
if ( prop is TProp typedProp ) {
87
102
if ( ! typedProp . UpdateIfChanged ( value ) ) return ;
88
-
89
- if ( ! SuppressEagerUpdate ) {
90
- OnValueChanged ? . Invoke ( this , id ) ;
91
- } else {
92
- NeedsValueUpdate = true ;
93
- }
94
-
103
+ FireOnValueChanged ( id ) ;
95
104
return ;
96
105
}
97
106
@@ -100,12 +109,7 @@ private void _internalSet<T, TProp>(int id, T value) where TProp : Prop<T>
100
109
}
101
110
102
111
props [ id ] = ( TProp ) Activator . CreateInstance ( typeof ( TProp ) , value ) ;
103
-
104
- if ( ! SuppressEagerUpdate ) {
105
- OnEntriesChanged ? . Invoke ( this ) ;
106
- } else {
107
- NeedsEntriesUpdate = true ;
108
- }
112
+ FireOnEntriesChanged ( ) ;
109
113
}
110
114
111
115
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -117,13 +121,25 @@ private void _internalSet<T, TProp>(int id, T value) where TProp : Prop<T>
117
121
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
118
122
public void SetInt ( int id , int value ) => _internalSet < int , PropInt > ( id , value ) ;
119
123
124
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
120
125
public void SetTexture ( int id , Texture value ) => _internalSet < Texture , PropTexture > ( id , value ) ;
126
+
127
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
121
128
public void SetVector ( int id , Vector4 value ) => _internalSet < Vector4 , PropVector > ( id , value ) ;
122
129
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
+
123
138
#endregion
124
139
125
140
#region Has
126
141
142
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
127
143
private bool _internalHas < T > ( int id ) => props . TryGetValue ( id , out var prop ) && prop is Prop < T > ;
128
144
129
145
public bool HasColor ( int id ) => _internalHas < Color > ( id ) ;
0 commit comments