You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure whether this is expected behaviour or not, but I could not find any reference in the documentation to static fields not being supported.
I am trying to reload a static class that has a static Material field that is assigned on startup via reflection.
The static class content looks like this:
privatestaticMaterialmaterial;publicstaticvoidDrawReticleCircle(inReticleDrawArgsargs){varposition=args.WorldPosition;// ...Graphics.DrawMesh(mesh,trs,material,0);}staticvoidOnScriptHotReloadNoInstance(){Debug.Log($"Post-reload, asset is {material} (null={material==null})");}
After changing the contents of DrawReticleCircle, the script is reloaded but the value of material is lost.
The debug log reads: Post-reload, asset is (null=True)
I would expect for the value to be copied over, or for the new code to reference the field in the old assembly (if this is possible?).
Is this a known limitation or a bug? If it is a limitation, I think it is worth pointing out in the documentation.
Thanks.
The text was updated successfully, but these errors were encountered:
handzlikchris
changed the title
Static fields are lost upon reload
Static fields in changed code are lost upon reload
Nov 20, 2023
I am not sure whether this is expected behaviour or not, but I could not find any reference in the documentation to static fields not being supported.
I am trying to reload a static class that has a static
Material
field that is assigned on startup via reflection.The static class content looks like this:
After changing the contents of DrawReticleCircle, the script is reloaded but the value of
material
is lost.The debug log reads:
Post-reload, asset is (null=True)
I would expect for the value to be copied over, or for the new code to reference the field in the old assembly (if this is possible?).
Is this a known limitation or a bug? If it is a limitation, I think it is worth pointing out in the documentation.
Thanks.
The text was updated successfully, but these errors were encountered: