handzlikchris / handzlikchris/FastScriptReload

Static fields in changed code are lost upon reload

Abierto
#110 1 comentario 0 reacciones 0 asignados Ver en GitHub
feature
Lenguaje dominante
C#
Estrellas
2.2k
Forks
167
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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:
```C#
private static Material material;

public static void DrawReticleCircle(in ReticleDrawArgs args)
{
var position = args.WorldPosition;
// ...
Graphics.DrawMesh(mesh, trs, material, 0);
}

static void OnScriptHotReloadNoInstance()
{
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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Reproduce el problema en Unity con una clase estática que contenga un campo Material obtenido mediante reflexión; después edita DrawReticleCircle y observa el registro OnScriptHotReloadNoInstance. Lee el manejo de hot-reload de los campos estáticos y determina si la pérdida del valor es esperada o constituye un defecto. Se considera terminado cuando el comportamiento se haya corregido o su limitación esté claramente documentada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, unity
Área
game-dev, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.