mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: fixing Initializer for generic synclists (#2328)
Weaver should initialize `public SyncList<int> myList;` in the same way it does for `SyncListInt`
This commit is contained in:
parent
ad48d511a1
commit
9bf8817245
@ -46,6 +46,13 @@ static void GenerateSyncObjectInstanceInitializer(ILProcessor worker, FieldDefin
|
|||||||
}
|
}
|
||||||
MethodReference objectConstructor = Weaver.CurrentAssembly.MainModule.ImportReference(ctor);
|
MethodReference objectConstructor = Weaver.CurrentAssembly.MainModule.ImportReference(ctor);
|
||||||
|
|
||||||
|
// if is SyncList<int> instead of SyncListInt then we need to make the ctor generic
|
||||||
|
if (fd.FieldType.IsGenericInstance)
|
||||||
|
{
|
||||||
|
GenericInstanceType genericInstance = (GenericInstanceType)fd.FieldType;
|
||||||
|
objectConstructor = objectConstructor.MakeHostInstanceGeneric(genericInstance);
|
||||||
|
}
|
||||||
|
|
||||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||||
worker.Append(worker.Create(OpCodes.Newobj, objectConstructor));
|
worker.Append(worker.Create(OpCodes.Newobj, objectConstructor));
|
||||||
worker.Append(worker.Create(OpCodes.Stfld, fd));
|
worker.Append(worker.Create(OpCodes.Stfld, fd));
|
||||||
|
Loading…
Reference in New Issue
Block a user