diff --git a/Assets/Mirror/Weaver/Processors/SyncVarProcessor.cs b/Assets/Mirror/Weaver/Processors/SyncVarProcessor.cs index 0fa0ba53a..6951bb3d5 100644 --- a/Assets/Mirror/Weaver/Processors/SyncVarProcessor.cs +++ b/Assets/Mirror/Weaver/Processors/SyncVarProcessor.cs @@ -159,7 +159,6 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, List syncVars, List syncObjects, List syncVarNetIds) diff --git a/Assets/Mirror/Weaver/Weaver.cs b/Assets/Mirror/Weaver/Weaver.cs index de1584aa7..eb8581c14 100644 --- a/Assets/Mirror/Weaver/Weaver.cs +++ b/Assets/Mirror/Weaver/Weaver.cs @@ -13,10 +13,8 @@ namespace Mirror.Weaver // This data is flushed each time - if we are run multiple times in the same process/domain class WeaverLists { - // [SyncVar] member variables that should be replaced - public List replacedFields = new List(); - // setter functions that replace [SyncVar] member variable references - public List replacementProperties = new List(); + // setter functions that replace [SyncVar] member variable references. dict + public Dictionary replacementSetterProperties = new Dictionary(); // GameObject SyncVar generated netId fields public List netIdFields = new List(); @@ -751,18 +749,14 @@ static void ProcessInstructionSetterField(TypeDefinition td, MethodDefinition md return; // does it set a field that we replaced? - for (int n = 0; n < lists.replacedFields.Count; n++) + MethodDefinition replacement; + if (lists.replacementSetterProperties.TryGetValue(opField, out replacement)) { - FieldDefinition fd = lists.replacedFields[n]; - if (opField == fd) - { - //replace with property - //DLog(td, " replacing " + md.Name + ":" + i); - i.OpCode = OpCodes.Call; - i.Operand = lists.replacementProperties[n]; - //DLog(td, " replaced " + md.Name + ":" + i); - break; - } + //replace with property + //DLog(td, " replacing " + md.Name + ":" + i); + i.OpCode = OpCodes.Call; + i.Operand = replacement; + //DLog(td, " replaced " + md.Name + ":" + i); } }