@@ -593,6 +593,7 @@ internal void SyncVarUpdate()
593593 FieldTypeHelper . WriteFieldType ( writer , syncedVarFields [ i ] . FieldInfo . GetValue ( this ) , syncedVarFields [ i ] . FieldValue ) ;
594594 syncedVarFields [ i ] . FieldValue = FieldTypeHelper . GetReferenceArrayValue ( syncedVarFields [ i ] . FieldInfo . GetValue ( this ) , syncedVarFields [ i ] . FieldValue ) ;
595595 syncedVarFields [ i ] . Dirty = false ;
596+ InvokeSyncvarMethodOnServer ( syncedVarFields [ i ] . HookMethod ) ;
596597 }
597598 }
598599 List < uint > stillDirtyIds = InternalMessageHandler . Send ( "MLAPI_SYNC_VAR_UPDATE" , "MLAPI_INTERNAL" , writer , networkId ) ;
@@ -628,6 +629,7 @@ internal void SyncVarUpdate()
628629 //Only targeted SyncedVars were changed. Thus we need to set them as non dirty here since it wont be done by the next loop.
629630 syncedVarFields [ i ] . FieldValue = FieldTypeHelper . GetReferenceArrayValue ( syncedVarFields [ i ] . FieldInfo . GetValue ( this ) , syncedVarFields [ i ] . FieldValue ) ;
630631 syncedVarFields [ i ] . Dirty = false ;
632+ InvokeSyncvarMethodOnServer ( syncedVarFields [ i ] . HookMethod ) ;
631633 }
632634 }
633635 }
@@ -658,6 +660,7 @@ internal void SyncVarUpdate()
658660 FieldTypeHelper . WriteFieldType ( writer , syncedVarFields [ i ] . FieldInfo . GetValue ( this ) , syncedVarFields [ i ] . FieldValue ) ;
659661 syncedVarFields [ i ] . FieldValue = FieldTypeHelper . GetReferenceArrayValue ( syncedVarFields [ i ] . FieldInfo . GetValue ( this ) , syncedVarFields [ i ] . FieldValue ) ;
660662 syncedVarFields [ i ] . Dirty = false ;
663+ InvokeSyncvarMethodOnServer ( syncedVarFields [ i ] . HookMethod ) ;
661664 }
662665 }
663666 List < uint > stillDirtyIds = InternalMessageHandler . Send ( "MLAPI_SYNC_VAR_UPDATE" , "MLAPI_INTERNAL" , writer , ownerClientId , networkId , null , null ) ; // Send to everyone except target.
@@ -670,6 +673,12 @@ internal void SyncVarUpdate()
670673 }
671674 }
672675
676+ private void InvokeSyncvarMethodOnServer ( MethodInfo hookMethod )
677+ {
678+ if ( isServer && hookMethod != null )
679+ hookMethod . Invoke ( this , null ) ;
680+ }
681+
673682 private bool SetDirtyness ( )
674683 {
675684 if ( ! isServer )
0 commit comments