File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class SyncedVar : Attribute
11
11
/// <summary>
12
12
/// The method name to invoke when the SyncVar get's updated.
13
13
/// </summary>
14
- public string hook ;
14
+ public string hookMethodName ;
15
15
/// <summary>
16
16
/// If true, the syncedVar will only be synced to the owner.
17
17
/// </summary>
Original file line number Diff line number Diff line change @@ -213,24 +213,24 @@ internal void SyncVarInit()
213
213
{
214
214
if ( sortedFields [ i ] . IsDefined ( typeof ( SyncedVar ) , true ) )
215
215
{
216
- object [ ] syncedVarAttributes = sortedFields [ i ] . GetCustomAttributes ( typeof ( SyncedVar ) , true ) ;
217
- MethodInfo method = null ;
218
- if ( ! string . IsNullOrEmpty ( ( ( SyncedVar ) syncedVarAttributes [ 0 ] ) . hook ) )
219
- {
220
- method = GetType ( ) . GetMethod ( ( ( SyncedVar ) syncedVarAttributes [ 0 ] ) . hook , BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Instance ) ;
221
- break ;
222
- }
216
+ SyncedVar attribute = ( ( SyncedVar ) sortedFields [ i ] . GetCustomAttributes ( typeof ( SyncedVar ) , true ) [ 0 ] ) ;
217
+
218
+ MethodInfo hookMethod = null ;
219
+
220
+ if ( ! string . IsNullOrEmpty ( attribute . hookMethodName ) )
221
+ hookMethod = GetType ( ) . GetMethod ( attribute . hookMethodName , BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Instance ) ;
222
+
223
223
FieldType fieldType = FieldTypeHelper . GetFieldType ( sortedFields [ i ] . FieldType ) ;
224
224
if ( fieldType != FieldType . Invalid )
225
225
{
226
226
syncedVarFields . Add ( new SyncedVarField ( )
227
227
{
228
228
Dirty = false ,
229
- Target = ( ( SyncedVar ) sortedFields [ i ] . GetCustomAttributes ( typeof ( SyncedVar ) , true ) [ 0 ] ) . target ,
229
+ Target = attribute . target ,
230
230
FieldInfo = sortedFields [ i ] ,
231
231
FieldType = fieldType ,
232
232
FieldValue = sortedFields [ i ] . GetValue ( this ) ,
233
- HookMethod = method
233
+ HookMethod = hookMethod
234
234
} ) ;
235
235
}
236
236
else
You can’t perform that action at this time.
0 commit comments