stop the Yarn setup menu from overwriting a real scene
Fixes "Can't start dialogue: no Yarn Project has been configured." Cause, and it was mine. Phase 3.7 said "retarget YarnDemoSetup.cs or retire it"; I retargeted it. But that menu does not modify a scene — it builds one from scratch and calls SaveScene over its target. Pointing it at SC101_ConferenceHall.unity armed it at the real level, and running it replaced the scene with a bare Yarn demo: ten of fourteen roots gone, including the player, the lighting and the navmesh. The leftover Dialogue System prefab instance it left behind had no yarnProject override, auto-started, and produced the error. The scene was committed, so nothing was lost; it is restored from HEAD at 14 roots with its sun reference intact. The menu now targets Assets/Scenes/Dev/YarnSandbox.unity and refuses to run if its target is not under Scenes/Dev, via ScenePaths.IsDisposable. It is renamed to "Set Up Yarn Sandbox Scene" so the menu says what it does. The other three setup menus open and modify their target rather than regenerating it, so they were never affected and are unchanged. The test suite could not have caught this, because it asserted only that a DialogueRunner existed. TheDialogueRunner_HasItsYarnProject now asserts there is exactly one runner across the loaded scenes and that its project is set and compiled — which reproduces the failure exactly when the scene is broken. Also here: four UI prefabs pick up m_EditorClassIdentifier changes from Assembly-CSharp to NightclubArcadia.Game, written by Unity after the assembly split in the previous commit. Expected and correct. EditMode 42/42, PlayMode 6/6, YarnCheck 9 files / 35 nodes. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -15,7 +15,30 @@ namespace NightclubArcadia.EditorTools
|
||||
/// <summary>Persistent systems: dialogue, skills, UI, camera rig, player.</summary>
|
||||
public const string Systems = "Assets/Scenes/Systems/Systems.unity";
|
||||
|
||||
/// <summary>The scene the setup menus wire into. SC-101's conference hall.</summary>
|
||||
/// <summary>
|
||||
/// The scene the setup menus wire into. SC-101's conference hall.
|
||||
///
|
||||
/// Only for menus that OPEN and MODIFY a scene. A menu that builds a scene from
|
||||
/// scratch and saves over its target must never point here — see Sandbox.
|
||||
/// </summary>
|
||||
public const string WorkingLevel = "Assets/Scenes/Levels/SC101_ConferenceHall.unity";
|
||||
|
||||
/// <summary>
|
||||
/// Scratch scene for menus that generate a scene wholesale.
|
||||
///
|
||||
/// This exists because pointing such a menu at WorkingLevel destroyed it once:
|
||||
/// YarnDemoSetup builds a demo scene and calls SaveScene over its target, so
|
||||
/// running it replaced SC-101 with a bare Yarn demo. Anything under Scenes/Dev
|
||||
/// is disposable by definition; nothing outside it is.
|
||||
/// </summary>
|
||||
public const string Sandbox = "Assets/Scenes/Dev/YarnSandbox.unity";
|
||||
|
||||
/// <summary>
|
||||
/// Guard for any menu that overwrites a whole scene. Generated scenes belong in
|
||||
/// Scenes/Dev and nowhere else.
|
||||
/// </summary>
|
||||
public static bool IsDisposable(string scenePath) =>
|
||||
!string.IsNullOrEmpty(scenePath) &&
|
||||
scenePath.Replace('\\', '/').StartsWith("Assets/Scenes/Dev/", System.StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,27 @@ using Yarn.Unity.Editor;
|
||||
public static class YarnDemoSetup
|
||||
{
|
||||
const string YarnProjectPath = "Assets/Dialogue/NightclubArcadia.yarnproject";
|
||||
const string ScenePath = NightclubArcadia.EditorTools.ScenePaths.WorkingLevel;
|
||||
const string ScenePath = NightclubArcadia.EditorTools.ScenePaths.Sandbox;
|
||||
|
||||
[MenuItem("Tools/Nightclub Arcadia/Set Up Yarn Dialogue Test")]
|
||||
[MenuItem("Tools/Nightclub Arcadia/Set Up Yarn Sandbox Scene")]
|
||||
public static void SetUpYarnDialogueTest()
|
||||
{
|
||||
// This menu BUILDS A SCENE FROM SCRATCH and saves over ScenePath. Pointed at a
|
||||
// real level it silently destroys it, which is exactly what happened when it
|
||||
// was briefly retargeted at SC101_ConferenceHall. The guard is the fix; do not
|
||||
// remove it, and do not point ScenePath outside Scenes/Dev.
|
||||
if (!NightclubArcadia.EditorTools.ScenePaths.IsDisposable(ScenePath))
|
||||
{
|
||||
Debug.LogError($"Refusing to run: '{ScenePath}' is not under Assets/Scenes/Dev/. " +
|
||||
"This menu overwrites its target scene wholesale.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AssetDatabase.IsValidFolder("Assets/Scenes/Dev"))
|
||||
{
|
||||
AssetDatabase.CreateFolder("Assets/Scenes", "Dev");
|
||||
}
|
||||
|
||||
if (!AssetDatabase.IsValidFolder("Assets/TextMesh Pro"))
|
||||
{
|
||||
Debug.LogWarning("TextMesh Pro essential resources are missing. Run Window → TextMeshPro → Import TMP Essential Resources.");
|
||||
|
||||
Reference in New Issue
Block a user