handzlikchris / handzlikchris/FastScriptReload

Static fields in changed code are lost upon reload

オープン
#110 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
feature
主要言語
C#
スター
2.2k
フォーク
167
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Unity で、リフレクションによって取得される Material フィールドを含む静的クラスを使って問題を再現し、その後 DrawReticleCircle を編集して OnScriptHotReloadNoInstance ログを確認します。静的フィールドのホットリロード処理を読み、失われた値が想定されたものか、それとも不具合なのかを判断します。動作が解決されるか、その制限が明確に文書化されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, unity
領域
game-dev, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。