JetBrains Rider 2026.1 Help

代码检查:不支持写入 static 字段

Burst 不支持写入 static 状态。 通常发生在 [BurstCompile] 作业或其他 Burst 编译的方法中。

示例

在此示例中, counter 字段被声明为 static。 在 执行 方法中的 [BurstCompile] 作业内写入该字段不受支持。

using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { private static int counter; public void Execute() { // Reported: Writing to a static field is not supported counter = 1; } }
using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { public int counter; public void Execute() { // Correct: Use instance fields or native containers instead counter = 1; } }

快速修复

此检查不提供专用快速修复。 请手动修复,将 static 写入移除,并将状态转移到 Burst 兼容的数据中,例如实例字段、作业数据或受支持的原生容器。

2026年 5月 8日