Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Static fields in changed code are lost upon reload

オープン
#110 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

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

調査の方向性

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

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

説明

feature

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:

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.

主要言語
C#
スター
2.2k
フォーク
167
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

handzlikchris/FastScriptReload のほかの issue

handzlikchris/FastScriptReload の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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