ReSharper 2026.1 Help

代码检查:构建设置中没有同名场景。

此检查会在项目中存在该场景但未在 Unity 构建设置中添加时,报告传递给 SceneManager.LoadScene(...) 及相关 API 的场景名称。

这不同于完全丢失的场景文件。 当字符串指向一个真实的场景资源,但该场景未包含在 EditorBuildSettings 中,导致无法在运行时通过名称加载时,该检查会发出警告。

示例

在此示例中,已加载 "Gameplay" 场景,但未将其添加到 Build Settings。 快速修复会将该场景添加到 Build Settings。

using UnityEngine.SceneManagement; public class Example { public void Load() { // Reported: scene 'Gameplay' is not in build settings SceneManager.LoadScene("Gameplay"); } }
using UnityEngine.SceneManagement; public class Example { public void Load() { // Scene 'Gameplay' is added to build settings SceneManager.LoadScene("Scenes/Gameplay"); } }

快速修复

快速修复可以将匹配场景添加到 Unity 构建设置中。 如果有多个场景共享相同短名称,也可以用确切的场景路径替换参数。

在具有多个匹配场景的项目中,请选择所需场景项,以便调用也能更新为正确的基于路径的名称。

2026年 5月 8日