A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(map): legible 1948 labels, continuous hex outlines, stable Map.unity, stricter settlement parsing
eyalgolan9e844c626bba
diff --git a/docs/m2-geography-check.md b/docs/m2-geography-check.mdindex 5bc93a12c..e5835fa78 100644--- a/docs/m2-geography-check.md+++ b/docs/m2-geography-check.md@@ -1,14 +1,41 @@# M2 geography check (captures/topdown.png vs promo/ref/geo-reference.png)-Checked on 2026-10-10 against `captures/topdown.png` (749×2000, `MapCapture.TopDown`, batch mode with graphics), `promo/ref/geo-reference.png` (a schematic, not to scale) and `tools/preview_map.py`'s image. Flythrough frames 0, 120 and 239 were also checked.+Redone on 2026-10-10 against the merged m0-m2 tree, which has the climatology biomes, the K2 overlay fix and the K1 labels. Images checked:+- `captures/topdown.png` (749×2000, `MapCapture.TopDown`, batch mode with graphics)+- `promo/ref/geo-reference.png` (a schematic, not to scale)+- `tools/preview_map.py`'s image+- flythrough frames 0, 60, 120, 180 and 239-- [x] Coast on the west; Carmel ridge reaching the coast at Haifa — PASS. The sea fills the west edge. The Haifa marker sits on the headland, with Haifa Bay and Acre to its north. The Carmel relief runs south-east from it (clearest in flythrough frame 239).+- [x] Coast on the west; Carmel ridge reaching the coast at Haifa — PASS. The sea fills the west edge. The Haifa marker sits on the headland, with Haifa Bay and Acre to its north. With the fine terrain LOD, the Carmel relief can be seen running south-east from Haifa (clearest in flythrough frame 239).- [x] Sea of Galilee north-east; Jordan valley running south to the Dead Sea — PASS. The Galilee lake is at about 35.6E 32.8N. A low valley runs south from it to the Dead Sea along the east side of the land.-- [x] Dead Sea's north tip level with Jerusalem; Jerusalem south-east of Tel Aviv — PASS. In the top-down image the Dead Sea's north tip is at row ≈ 400/1000 and Jerusalem's marker at ≈ 402/1000. Jerusalem is east and south of Tel Aviv.-- [x] Negev widening to the south; Beersheba inland, south of the coastal plain — PASS, with a note. The coast turns west and leaves the frame near Rafah (31.3N), so the land widens south of it. Beersheba sits inland, just south of where the green coastal plain ends. The Negev's triangle shape is not drawn, because the frame includes Sinai and Jordan with no borders. Known data issue, being fixed elsewhere: this branch's hexes.json still uses the old biome rule, which draws a straight desert edge near 31.25N.-- [x] Every 1948 settlement marker sits on its correct place (spot-check Tel Aviv, Jaffa, Haifa, Jerusalem, Beersheba, Tiberias) — PASS. The edit-mode test `EveryMarkerSitsOnItsSourcedPositionWithTheMarkerMaterial` checks all 25 markers against `GeoFrame.ToWorld` (within 1 m). By eye: Tel Aviv and Jaffa are on the coast, Jaffa just south; Haifa is at the Carmel tip; Jerusalem is in the hills; Beersheba is inland in the northern Negev; Tiberias is on the Sea of Galilee's west shore. The DEM elevation is above sea or lake level at all 25 points.-- [x] No settlement in the sea; no hex outline over open sea — PASS. Outlines are drawn only for land hexes. Coastal hexes overhang the shoreline by part of a hex, but none sits over open sea. No marker is on water.+- [x] Dead Sea's north tip level with Jerusalem; Jerusalem south-east of Tel Aviv — PASS. In the top-down image the Dead Sea's north tip and Jerusalem's marker are both at row ≈ 400/1000. Jerusalem is east and south of Tel Aviv. The same layout shows in flythrough frame 60.+- [x] Negev widening to the south; Beersheba inland, south of the coastal plain — PASS (partly checkable). These parts can be checked:+ - The coast turns west and leaves the frame near Rafah (31.3N).+ - Beersheba sits inland, at the southern edge of the green coastal plain, where the desert begins (31.25–31.3N in the climatology biomes).-Unity's render and `tools/preview_map.py`'s preview agree on the coastline, the lakes, the Jordan valley and every settlement position. They differ only in biome palette.+ This part cannot be checked: the Negev's own triangle. The frame includes Sinai and Jordan, and the map draws no borders, so the desert runs the full width of the frame. The widening can be judged only from the coastline, not from the Negev's outline.+- [x] Every 1948 settlement marker sits on its correct place (spot-check Tel Aviv, Jaffa, Haifa, Jerusalem, Beersheba, Tiberias) — PASS.+ - Edit-mode tests check all 25 markers against `GeoFrame.ToWorld` (within 1 m). They also check the frame against the heightmap meta, and Jerusalem's position computed independently.+ - By eye and in the labelled flythrough:+ - Tel Aviv and Jaffa are on the coast, Jaffa just south.+ - Haifa is at the Carmel tip.+ - Jerusalem is in the hills.+ - Beersheba is inland in the northern Negev.+ - Tiberias is on the Sea of Galilee's west shore.+- [x] No settlement in the sea; no hex outline over open sea — PASS.+ - Markers: "no marker on water" rests on a DEM check. The DEM elevation at all 25 coordinates is above sea level, or above the Galilee lake surface (−210 m) for Tiberias (−135 m) and Degania (−197 m).+ - In the image, the Tiberias marker appears inside the lake's blue tint. That is because biome colours blend over about a hex near the shore; it is not a placement error.+ - Outlines are drawn only for land hexes. Coastal hexes overhang the shoreline by part of a hex; none sits over open sea.-Result: PASS (geography). Presentation notes, not blocking: the labels (TextMesh with characterSize 400, per the brief) cannot be read in the top-down image (about 2 px). In the 1920×1080 flythrough they can be read but are small and low in contrast, and the Tel Aviv label is partly hidden by its own box. In the hills, terrain hides parts of some hex outlines (an overlay drape issue from Task 24).+Unity's render and `tools/preview_map.py`'s preview agree on:+- the coastline, the lakes and the Jordan valley;+- the desert edge (both follow `hexes.json`);+- every settlement position.++They differ only in biome palette.++Result: PASS (geography).++Presentation, not blocking:+- The labels are sized for the 1080p flythrough (see the task 25 report for measured sizes).+- In the top-down image they are small and foreshortened, because they face the 50-degree flythrough camera.diff --git a/unity/Assets/Editor/MapCapture.cs b/unity/Assets/Editor/MapCapture.csindex 953405321..471e91e0c 100644--- a/unity/Assets/Editor/MapCapture.cs+++ b/unity/Assets/Editor/MapCapture.cs@@ -25,6 +25,16 @@ public static class MapCaptureEditorSceneManager.SaveScene(scene, ScenePath);}+ /// <summary>Opens Assets/Map.unity (creating it only when missing) and builds the map in memory. The scene is not+ /// saved, so captures leave it unchanged.</summary>+ static MapScene OpenAndBuild()+ {+ if (AssetDatabase.LoadAssetAtPath<SceneAsset>(ScenePath) == null) MakeScene();+ else EditorSceneManager.OpenScene(ScenePath, OpenSceneMode.Single);+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ return map;+ }+static Material Load(string path){var m = AssetDatabase.LoadAssetAtPath<Material>(path);@@ -35,8 +45,7 @@ public static class MapCapture/// <summary>Orthographic straight-down render of the whole map, for comparison with promo/ref/geo-reference.png.</summary>public static void TopDown(){- MakeScene();- var map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ var map = OpenAndBuild();var cam = new GameObject("TopCam").AddComponent<Camera>();var size = map.Terrain.terrainData.size;cam.orthographic = true; cam.orthographicSize = size.z / 2; cam.aspect = size.x / size.z;@@ -48,8 +57,7 @@ public static class MapCapture/// <summary>240 frames flying north along the coast at diorama pitch; encode with ffmpeg.</summary>public static void Flythrough(){- MakeScene();- var map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ var map = OpenAndBuild();var rig = Camera.main.GetComponent<CameraRig>();var dir = Path.Combine(CaptureDir, "fly"); Directory.CreateDirectory(dir);for (int i = 0; i < 240; i++)diff --git a/unity/Assets/Scripts/Map/MapBuilder.cs b/unity/Assets/Scripts/Map/MapBuilder.csindex a58c380aa..c06cc8184 100644--- a/unity/Assets/Scripts/Map/MapBuilder.cs+++ b/unity/Assets/Scripts/Map/MapBuilder.cs@@ -15,6 +15,10 @@ namespace Statecraft.Game.Mappublic const float BiomeLayerTileSizeM = 1000f; // layers are flat colours, so the tiling only needs to be finitepublic const int OverlaySegmentsPerEdge = 10; // ~500 m sub-segments on a 5 km hex edge, each draped on the terrainpublic const float OverlayClearanceM = 40f * VerticalExaggeration; // above the (exaggerated) terrain surface+ public const int OverlaySamplesPerSegment = 16; // ~31 m steps, finer than the ~79 m heightmap spacing+ /// <summary>Terrain LOD screen-space error in pixels. Unity's default (5) gives distant cameras (the top-down+ /// capture, the 90 km flythrough) a coarse surface that rises above the draped hex outlines in valleys (K2).</summary>+ public const float TerrainPixelError = 1f;static readonly Dictionary<string, Color> Biome = new Dictionary<string, Color>{@@ -46,7 +50,9 @@ namespace Statecraft.Game.MapterrainGo.name = "Terrain";var assets = terrainGo.AddComponent<MapRuntimeAssets>();assets.Own(data);- terrainGo.GetComponent<Terrain>().materialTemplate = terrainMaterial;+ var terrain = terrainGo.GetComponent<Terrain>();+ terrain.materialTemplate = terrainMaterial;+ terrain.heightmapPixelError = TerrainPixelError;ApplyBiomeColours(data, frame, hexFile, assets);var overlay = BuildHexOverlay(frame, hexFile, data, overlayMaterial, assets);@@ -108,28 +114,40 @@ namespace Statecraft.Game.Mapdata.SetAlphamaps(0, 0, a);}- /// <summary>Line mesh of every land hex outline. Each edge is split into OverlaySegmentsPerEdge sub-segments whose- /// vertices are draped OverlayClearanceM above the terrain; vertices are clamped to the terrain bounds.</summary>+ /// <summary>Line mesh of every land hex outline. Each edge is split into OverlaySegmentsPerEdge sub-segments; vertices+ /// are clamped to the terrain bounds. Each vertex sits OverlayClearanceM above the highest terrain sampled along its+ /// two adjacent sub-segments, so the straight line between two vertices clears any ridge between them.</summary>static GameObject BuildHexOverlay(GeoFrame frame, HexFile hexes, TerrainData data, Material material, MapRuntimeAssets assets){float size = hexes.hex_size_km * 1000f;int n = 6 * OverlaySegmentsPerEdge;var verts = new List<Vector3>(); var idx = new List<int>();- var corners = new Vector2[6];+ var corners = new Vector2[6]; var ground = new Vector2[n]; var segMax = new float[n];foreach (var h in hexes.hexes){if (!h.land) continue;var c = frame.ToWorld(h.lon, h.lat, 0);for (int i = 0; i < 6; i++) corners[i] = HexMath.Corner(new Vector2(c.x, c.z), size, i);- int start = verts.Count;for (int i = 0; i < 6; i++)for (int s = 0; s < OverlaySegmentsPerEdge; s++){var k = Vector2.Lerp(corners[i], corners[(i + 1) % 6], (float)s / OverlaySegmentsPerEdge);k.x = Mathf.Clamp(k.x, 0f, frame.WidthM); k.y = Mathf.Clamp(k.y, 0f, frame.LengthM);- float y = data.GetInterpolatedHeight(k.x / frame.WidthM, k.y / frame.LengthM) + OverlayClearanceM;- verts.Add(new Vector3(k.x, y, k.y));+ ground[i * OverlaySegmentsPerEdge + s] = k;+ }+ for (int j = 0; j < n; j++)+ {+ float m = float.MinValue;+ for (int t = 0; t <= OverlaySamplesPerSegment; t++)+ {+ var p = Vector2.Lerp(ground[j], ground[(j + 1) % n], (float)t / OverlaySamplesPerSegment);+ m = Mathf.Max(m, data.GetInterpolatedHeight(p.x / frame.WidthM, p.y / frame.LengthM));}+ segMax[j] = m;+ }+ int start = verts.Count;+ for (int j = 0; j < n; j++)+ verts.Add(new Vector3(ground[j].x, Mathf.Max(segMax[(j + n - 1) % n], segMax[j]) + OverlayClearanceM, ground[j].y));for (int i = 0; i < n; i++) { idx.Add(start + i); idx.Add(start + (i + 1) % n); }}var mesh = assets.Own(new Mesh { name = "HexOverlay", indexFormat = UnityEngine.Rendering.IndexFormat.UInt32 });diff --git a/unity/Assets/Scripts/Map/MapScene.cs b/unity/Assets/Scripts/Map/MapScene.csindex 61cebac53..0c91952f6 100644--- a/unity/Assets/Scripts/Map/MapScene.cs+++ b/unity/Assets/Scripts/Map/MapScene.cs@@ -12,7 +12,6 @@ namespace Statecraft.Game.Mappublic GeoFrame Frame { get; private set; }public Terrain Terrain { get; private set; }- GameObject _settlements, _postFx;void Awake() => Build();@@ -34,23 +33,30 @@ namespace Statecraft.Game.Mapvar size = Terrain.terrainData.size;var (meta, _) = HeightmapLoader.Load(Paths.StreamingMap);Frame = new GeoFrame(meta.lon0, meta.lon1, meta.lat0, meta.lat1, size.x, size.z);- var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")),- (meta.lon0, meta.lon1, meta.lat0, meta.lat1));- _settlements = SettlementPlacer.Place(list, Frame, Terrain, markerMaterial);- _settlements.transform.SetParent(transform, true);+ var yamlPath = Path.Combine(Paths.Content, "map", SettlementPlacer.DefaultFileName);+ var list = SettlementPlacer.Parse(File.ReadAllText(yamlPath), (meta.lon0, meta.lon1, meta.lat0, meta.lat1), yamlPath);+ SettlementPlacer.Place(list, Frame, Terrain, markerMaterial).transform.SetParent(transform, true);if (!cam.TryGetComponent(out CameraRig rig)) rig = cam.gameObject.AddComponent<CameraRig>();rig.LookAt = Frame.ToWorld(34.95, 31.95, 0); rig.Init(); // central Israel: Tel Aviv–Jerusalem corridor- _postFx = rig.Volume.gameObject; _postFx.transform.SetParent(transform, true);- terrainGo.GetComponent<MapRuntimeAssets>().Own(rig.Volume.profile);+ rig.Volume.transform.SetParent(transform, true);+ // VolumeProfile's own teardown only releases its components, it does not destroy them (Core RP 17.3), so own both.+ var assets = terrainGo.GetComponent<MapRuntimeAssets>();+ foreach (var c in rig.Volume.profile.components) assets.Own(c);+ assets.Own(rig.Volume.profile);}+ /// <summary>Destroys every child: all of them are things Build made (terrain, Settlements, PostFX). Walking the+ /// hierarchy rather than remembered fields keeps Build idempotent after a domain reload (R2). The VolumeProfile is+ /// owned by the terrain's MapRuntimeAssets, so destroying the terrain destroys it.</summary>void Clear(){- // The VolumeProfile is owned by the terrain's MapRuntimeAssets, so destroying the terrain destroys it.- foreach (var go in new[] { Terrain != null ? Terrain.gameObject : null, _settlements, _postFx })- if (go != null) { if (Application.isPlaying) Destroy(go); else DestroyImmediate(go); }- Terrain = null; _settlements = null; _postFx = null;+ for (int i = transform.childCount - 1; i >= 0; i--)+ {+ var go = transform.GetChild(i).gameObject;+ if (Application.isPlaying) { go.transform.SetParent(null); Destroy(go); } else DestroyImmediate(go);+ }+ Terrain = null;}}}diff --git a/unity/Assets/Scripts/Map/SettlementPlacer.cs b/unity/Assets/Scripts/Map/SettlementPlacer.csindex 55cd8850f..b3a5e0360 100644--- a/unity/Assets/Scripts/Map/SettlementPlacer.cs+++ b/unity/Assets/Scripts/Map/SettlementPlacer.cs@@ -1,6 +1,7 @@using System.Collections.Generic;using System.IO;using UnityEngine;+using YamlDotNet.Core;using YamlDotNet.Serialization;using YamlDotNet.Serialization.NamingConventions;@@ -11,7 +12,7 @@ namespace Statecraft.Game.Mappublic sealed class Settlement{public string Id { get; set; } = ""; public string Name { get; set; } = ""; public string Type { get; set; } = "";- public double Lon { get; set; } public double Lat { get; set; }+ public double Lon { get; set; } = double.NaN; public double Lat { get; set; } = double.NaN; // NaN = missingpublic int? Founded { get; set; } // null for pre-modern cities (no verifiable founding year)public bool PreModern { get; set; }public List<SourceRef> Sources { get; set; } = new List<SourceRef>();@@ -21,66 +22,112 @@ namespace Statecraft.Game.Mappublic static class SettlementPlacer{- static readonly Dictionary<string, (Color c, float h)> Marker = new Dictionary<string, (Color, float)>+ public const string DefaultFileName = "settlements_1948.yaml";++ // Marker colour and box edge (m); label cap height (m). Cap heights give >= 18 / 14 / 11 px at the top (farthest+ // edge, ~128 km) of a 1080p flythrough frame at the rig's 90 km distance and 35-degree FOV (K1).+ static readonly Dictionary<string, (Color c, float h, float cap)> Marker = new Dictionary<string, (Color, float, float)>+ {+ ["city"] = (new Color(0.93f, 0.92f, 0.88f), 1800f, 1500f), ["town"] = (new Color(0.88f, 0.84f, 0.76f), 1100f, 1150f),+ ["kibbutz"] = (new Color(0.80f, 0.35f, 0.25f), 600f, 900f), ["moshav"] = (new Color(0.78f, 0.45f, 0.30f), 600f, 900f),+ ["arab_town"] = (new Color(0.82f, 0.74f, 0.58f), 1100f, 1150f), ["village"] = (new Color(0.76f, 0.68f, 0.52f), 600f, 900f),+ };++ // Labels in the dense Tel Aviv - Lod cluster (and Safed / Rosh Pinna, 4 km apart) extend away from their neighbours+ // instead of centring on the marker.+ static readonly Dictionary<string, TextAnchor> LabelAnchor = new Dictionary<string, TextAnchor>{- ["city"] = (new Color(0.93f, 0.92f, 0.88f), 1800f), ["town"] = (new Color(0.88f, 0.84f, 0.76f), 1100f),- ["kibbutz"] = (new Color(0.80f, 0.35f, 0.25f), 600f), ["moshav"] = (new Color(0.78f, 0.45f, 0.30f), 600f),- ["arab_town"] = (new Color(0.82f, 0.74f, 0.58f), 1100f), ["village"] = (new Color(0.76f, 0.68f, 0.52f), 600f),+ ["jaffa"] = TextAnchor.LowerRight, ["rishon_lezion"] = TextAnchor.LowerRight, ["ramla"] = TextAnchor.LowerRight,+ ["lod"] = TextAnchor.LowerLeft, ["petah_tikva"] = TextAnchor.LowerLeft,+ ["safed"] = TextAnchor.LowerRight, ["rosh_pinna"] = TextAnchor.LowerLeft,};+ public const int LabelFontSize = 64; // glyph raster size; characterSize scales it to world metres+ public const float CapHeightPerUnit = 4.5f; // cap height (m) per unit of characterSize at LabelFontSize+ public const float LabelLift = 0.75f; // label base above the marker top, in box edges: clears the box's far top edge at the rig pitch+ static readonly Color LabelColour = new Color(0.98f, 0.97f, 0.93f), ShadowColour = new Color(0.06f, 0.05f, 0.04f, 0.9f);+static readonly int BaseColor = Shader.PropertyToID("_BaseColor");- /// <summary>Parses settlements_1948.yaml. Content errors throw InvalidDataException naming the settlement id and the- /// field: unknown type, duplicate id, non-finite lon/lat (or outside <paramref name="bounds"/> when given), empty- /// sources, founded null without pre_modern: true.</summary>- public static List<Settlement> Parse(string yaml, (double lon0, double lon1, double lat0, double lat1)? bounds = null)+ /// <summary>Parses settlements_1948.yaml. Every malformed input throws InvalidDataException naming+ /// <paramref name="file"/>, and for content errors the settlement id and the field: YAML syntax, unknown keys or bad+ /// scalars; empty id or name; unknown type; duplicate id; missing or non-finite lon/lat (or outside+ /// <paramref name="bounds"/> when given); empty sources, or a source with an empty url or checked; founded null+ /// without pre_modern: true.</summary>+ public static List<Settlement> Parse(string yaml, (double lon0, double lon1, double lat0, double lat1)? bounds = null,+ string file = DefaultFileName){- var list = new DeserializerBuilder().WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Deserialize<SettlementFile>(yaml).Settlements;+ SettlementFile doc;+ try { doc = new DeserializerBuilder().WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Deserialize<SettlementFile>(yaml); }+ catch (YamlException e) { throw new InvalidDataException($"{file}: {e.Message}", e); }+ if (doc?.Settlements == null || doc.Settlements.Count == 0) throw new InvalidDataException($"{file}: no settlements");var ids = new HashSet<string>();- foreach (var s in list)+ foreach (var s in doc.Settlements){- if (!Marker.ContainsKey(s.Type)) throw new InvalidDataException($"settlements: '{s.Id}' has unknown type '{s.Type}'");- if (!ids.Add(s.Id)) throw new InvalidDataException($"settlements: '{s.Id}' duplicate id");- CheckCoord(s.Id, "lon", s.Lon, bounds?.lon0, bounds?.lon1);- CheckCoord(s.Id, "lat", s.Lat, bounds?.lat0, bounds?.lat1);- if (s.Sources == null || s.Sources.Count == 0) throw new InvalidDataException($"settlements: '{s.Id}' sources is empty");- if (s.Founded == null && !s.PreModern) throw new InvalidDataException($"settlements: '{s.Id}' founded is null without pre_modern: true");+ if (s == null || string.IsNullOrWhiteSpace(s.Id)) throw new InvalidDataException($"{file}: a settlement has an empty id");+ string at = $"{file}: '{s.Id}'";+ if (!ids.Add(s.Id)) throw new InvalidDataException($"{at} duplicate id");+ if (string.IsNullOrWhiteSpace(s.Name)) throw new InvalidDataException($"{at} has an empty name");+ if (s.Type == null || !Marker.ContainsKey(s.Type)) throw new InvalidDataException($"{at} has unknown type '{s.Type}'");+ CheckCoord(at, "lon", s.Lon, bounds?.lon0, bounds?.lon1);+ CheckCoord(at, "lat", s.Lat, bounds?.lat0, bounds?.lat1);+ if (s.Sources == null || s.Sources.Count == 0) throw new InvalidDataException($"{at} sources is empty");+ for (int i = 0; i < s.Sources.Count; i++)+ {+ if (string.IsNullOrWhiteSpace(s.Sources[i]?.Url)) throw new InvalidDataException($"{at} sources[{i}].url is empty");+ if (string.IsNullOrWhiteSpace(s.Sources[i].Checked)) throw new InvalidDataException($"{at} sources[{i}].checked is empty");+ }+ if (s.Founded == null && !s.PreModern) throw new InvalidDataException($"{at} founded is null without pre_modern: true");}- return list;+ return doc.Settlements;}- static void CheckCoord(string id, string field, double v, double? min, double? max)+ static void CheckCoord(string at, string field, double v, double? min, double? max){- if (double.IsNaN(v) || double.IsInfinity(v)) throw new InvalidDataException($"settlements: '{id}' {field} {v} is not finite");+ if (double.IsNaN(v) || double.IsInfinity(v)) throw new InvalidDataException($"{at} {field} is missing or not finite ({v})");if (min.HasValue && (v < min.Value || v > max.Value))- throw new InvalidDataException($"settlements: '{id}' {field} {v} outside the heightmap bounds {min.Value}..{max.Value}");+ throw new InvalidDataException($"{at} {field} {v} outside the heightmap bounds {min.Value}..{max.Value}");}/// <summary>Placeholder markers (real per-era prefabs come in M3/M4): a box sized by type plus a name label, under a- /// returned "Settlements" root. The box uses the editor-made <paramref name="markerMaterial"/> (no runtime- /// Shader.Find, M0 correction 1); the per-type colour goes through a MaterialPropertyBlock.</summary>+ /// returned "Settlements" root. The box is a plain MeshFilter + MeshRenderer (no collider) using the editor-made+ /// <paramref name="markerMaterial"/> (no runtime Shader.Find, M0 correction 1); the per-type colour goes through a+ /// MaterialPropertyBlock. The label is light text with a dark drop shadow, above the box, facing the rig's pitch.</summary>public static GameObject Place(List<Settlement> list, GeoFrame frame, Terrain terrain, Material markerMaterial){var root = new GameObject("Settlements"); var parent = root.transform;var font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");+ var cube = Resources.GetBuiltinResource<Mesh>("Cube.fbx");var block = new MaterialPropertyBlock();foreach (var s in list){var p = frame.ToWorld(s.Lon, s.Lat, 0); p.y = terrain.SampleHeight(p) + terrain.transform.position.y;- var (c, h) = Marker[s.Type];- var box = GameObject.CreatePrimitive(PrimitiveType.Cube); box.name = s.Id; box.transform.SetParent(parent);- box.transform.position = p + Vector3.up * h / 2; box.transform.localScale = new Vector3(h, h, h);- var r = box.GetComponent<Renderer>(); r.sharedMaterial = markerMaterial;+ var (c, h, cap) = Marker[s.Type];+ var box = new GameObject(s.Id); box.transform.SetParent(parent);+ box.AddComponent<MeshFilter>().sharedMesh = cube;+ var r = box.AddComponent<MeshRenderer>(); r.sharedMaterial = markerMaterial;block.SetColor(BaseColor, c); r.SetPropertyBlock(block);+ box.transform.position = p + Vector3.up * h / 2; box.transform.localScale = new Vector3(h, h, h);- var labelGo = new GameObject(s.Id + "_label");- labelGo.AddComponent<MeshRenderer>().sharedMaterial = font.material;- var label = labelGo.AddComponent<TextMesh>();- label.font = font; label.text = s.Name; label.characterSize = 400; label.anchor = TextAnchor.LowerCenter; label.color = Color.black;- labelGo.transform.position = p + Vector3.up * (h + 400); labelGo.transform.rotation = Quaternion.Euler(50, 0, 0);- labelGo.transform.SetParent(parent);+ var anchor = LabelAnchor.TryGetValue(s.Id, out var a) ? a : TextAnchor.LowerCenter;+ var label = MakeText(s.Id + "_label", s.Name, font, cap, anchor, LabelColour);+ label.transform.SetPositionAndRotation(p + Vector3.up * h * (1f + LabelLift), Quaternion.Euler(CameraRig.Pitch, 0, 0));+ label.transform.SetParent(parent, true);+ var shadow = MakeText("shadow", s.Name, font, cap, anchor, ShadowColour);+ shadow.transform.SetParent(label.transform, false);+ shadow.transform.localPosition = new Vector3(cap * 0.07f, -cap * 0.07f, cap * 0.05f); // down-right, behind}return root;}++ static GameObject MakeText(string name, string text, Font font, float capM, TextAnchor anchor, Color colour)+ {+ var go = new GameObject(name);+ go.AddComponent<MeshRenderer>().sharedMaterial = font.material;+ var t = go.AddComponent<TextMesh>();+ t.font = font; t.fontSize = LabelFontSize; t.characterSize = capM / CapHeightPerUnit;+ t.text = text; t.anchor = anchor; t.color = colour;+ return go;+ }}}diff --git a/unity/Assets/Tests/EditMode/MapTests.cs b/unity/Assets/Tests/EditMode/MapTests.csindex 24893ff96..ddee3a900 100644--- a/unity/Assets/Tests/EditMode/MapTests.cs+++ b/unity/Assets/Tests/EditMode/MapTests.cs@@ -139,6 +139,41 @@ public class MapTestsfinally { Object.DestroyImmediate(go); }}+ [Test]+ public void EveryPointAlongEveryOverlaySegmentLiesAboveTheTerrain()+ {+ // Vertices alone are not enough: a ridge between two draped vertices hides the straight line joining them (K2).+ var (terrainMat, overlayMat) = Materials();+ var go = MapBuilder.Build(Paths.StreamingMap, HexesJson, terrainMat, overlayMat);+ try+ {+ var data = go.GetComponent<Terrain>().terrainData;+ var mesh = go.transform.Find("HexOverlay").GetComponent<MeshFilter>().sharedMesh;+ var verts = mesh.vertices; var idx = mesh.GetIndices(0);+ int hidden = 0; float worst = 0f;+ for (int i = 0; i < idx.Length; i += 2)+ for (int k = 1; k < 8; k++)+ {+ var p = Vector3.Lerp(verts[idx[i]], verts[idx[i + 1]], k / 8f);+ float deficit = data.GetInterpolatedHeight(p.x / data.size.x, p.z / data.size.z) - p.y;+ if (deficit >= 0f) hidden++;+ worst = Mathf.Max(worst, deficit);+ }+ Assert.AreEqual(0, hidden, $"points along overlay segments at or below the terrain (worst {worst:F0} m below)");+ }+ finally { Object.DestroyImmediate(go); }+ }++ [Test]+ public void TerrainUsesFineLodSoTheCoarseSurfaceDoesNotCoverTheOverlay()+ {+ // At the default heightmapPixelError (5) far cameras get a coarse LOD whose surface sits above the draped lines (K2).+ var (terrainMat, overlayMat) = Materials();+ var go = MapBuilder.Build(Paths.StreamingMap, HexesJson, terrainMat, overlayMat);+ try { Assert.AreEqual(MapBuilder.TerrainPixelError, go.GetComponent<Terrain>().heightmapPixelError); Assert.AreEqual(1f, MapBuilder.TerrainPixelError); }+ finally { Object.DestroyImmediate(go); }+ }+// --- Runtime-created objects are owned and destroyed with the map (L5) ---[Test]diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.csindex 20eb67281..59906004c 100644--- a/unity/Assets/Tests/EditMode/SettlementTests.cs+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs@@ -1,20 +1,33 @@+using System.Collections.Generic;using System.IO;using NUnit.Framework;using Statecraft.Game;using Statecraft.Game.Map;using UnityEditor;+using UnityEditor.SceneManagement;using UnityEngine;using UnityEngine.Rendering;+using UnityEngine.Rendering.Universal;public class SettlementTests{- static readonly (double, double, double, double) Bounds = (34.20, 35.90, 29.45, 33.35); // heightmap.json lon0, lon1, lat0, lat1+ static readonly HeightmapMeta Meta = HeightmapLoader.Load(Paths.StreamingMap).meta;+ static (double, double, double, double) Bounds => (Meta.lon0, Meta.lon1, Meta.lat0, Meta.lat1);+ static string RealYamlPath => Path.Combine(Paths.Content, "map", "settlements_1948.yaml");- static string Entry(string id, string extra = "lon: 35, lat: 32, type: town, founded: 1900, sources: [{url: u, checked: x}]") =>+ const string Src = "sources: [{url: u, checked: x}]";++ static string Entry(string id, string extra = "lon: 35, lat: 32, type: town, founded: 1900, " + Src) =>$"- {{id: {id}, name: N, {extra}}}\n";- static InvalidDataException Rejects(string yaml) =>- Assert.Throws<InvalidDataException>(() => SettlementPlacer.Parse("settlements:\n" + yaml, Bounds));+ static InvalidDataException Rejects(string entries) =>+ Assert.Throws<InvalidDataException>(() => SettlementPlacer.Parse("settlements:\n" + entries, Bounds));++ static void AssertNames(InvalidDataException ex, string id, string field)+ {+ StringAssert.Contains(SettlementPlacer.DefaultFileName, ex.Message);+ StringAssert.Contains($"'{id}'", ex.Message); StringAssert.Contains(field, ex.Message);+ }[Test]public void ParsesYamlAndRejectsUnknownType()@@ -24,135 +37,202 @@ public class SettlementTestsAssert.Throws<InvalidDataException>(() => SettlementPlacer.Parse("settlements:\n- {id: q, name: Q, lon: 35, lat: 32, type: castle, founded: 1900, sources: [{url: u, checked: x}]}\n"));}- [Test]- public void UnknownTypeNamesIdAndField()- {- var ex = Rejects(Entry("q", "lon: 35, lat: 32, type: castle, founded: 1900, sources: [{url: u, checked: x}]"));- StringAssert.Contains("'q'", ex.Message); StringAssert.Contains("type", ex.Message);- }+ [Test] public void UnknownTypeNamesIdAndField() =>+ AssertNames(Rejects(Entry("q", "lon: 35, lat: 32, type: castle, founded: 1900, " + Src)), "q", "type");- [Test]- public void DuplicateIdIsRejected()- {- var ex = Rejects(Entry("a") + Entry("a"));- StringAssert.Contains("'a'", ex.Message); StringAssert.Contains("id", ex.Message);- }+ [Test] public void DuplicateIdIsRejected() => AssertNames(Rejects(Entry("a") + Entry("a")), "a", "id");- [Test]- public void NonFiniteCoordinateIsRejected()- {- var ex = Rejects(Entry("n", "lon: .nan, lat: 32, type: town, founded: 1900, sources: [{url: u, checked: x}]"));- StringAssert.Contains("'n'", ex.Message); StringAssert.Contains("lon", ex.Message);- }+ [Test] public void NonFiniteCoordinateIsRejected() =>+ AssertNames(Rejects(Entry("n", "lon: .nan, lat: 32, type: town, founded: 1900, " + Src)), "n", "lon");[Test]public void CoordinateOutsideHeightmapBoundsIsRejected(){- var ex = Rejects(Entry("cy", "lon: 33.36, lat: 35.17, type: town, founded: 1900, sources: [{url: u, checked: x}]")); // Nicosia- StringAssert.Contains("'cy'", ex.Message); StringAssert.Contains("lon", ex.Message);- ex = Rejects(Entry("s", "lon: 35, lat: 29.40, type: town, founded: 1900, sources: [{url: u, checked: x}]"));- StringAssert.Contains("'s'", ex.Message); StringAssert.Contains("lat", ex.Message);+ AssertNames(Rejects(Entry("cy", "lon: 33.36, lat: 35.17, type: town, founded: 1900, " + Src)), "cy", "lon"); // Nicosia+ AssertNames(Rejects(Entry("s", "lon: 35, lat: 29.40, type: town, founded: 1900, " + Src)), "s", "lat");}+ [Test] public void MissingLonIsRejected() => AssertNames(Rejects(Entry("m", "lat: 32, type: town, founded: 1900, " + Src)), "m", "lon");+ [Test] public void MissingLatIsRejected() => AssertNames(Rejects(Entry("m", "lon: 35, type: town, founded: 1900, " + Src)), "m", "lat");++ [Test] public void EmptySourcesIsRejected() =>+ AssertNames(Rejects(Entry("e", "lon: 35, lat: 32, type: town, founded: 1900, sources: []")), "e", "sources");++ [Test] public void EmptySourceUrlIsRejected() =>+ AssertNames(Rejects(Entry("u", "lon: 35, lat: 32, type: town, founded: 1900, sources: [{url: '', checked: x}]")), "u", "url");++ [Test] public void EmptySourceCheckedIsRejected() =>+ AssertNames(Rejects(Entry("c", "lon: 35, lat: 32, type: town, founded: 1900, sources: [{url: u, checked: ''}]")), "c", "checked");++ [Test] public void NullFoundedNeedsPreModern() =>+ AssertNames(Rejects(Entry("f", "lon: 35, lat: 32, type: town, founded: null, " + Src)), "f", "founded");+[Test]- public void EmptySourcesIsRejected()+ public void EmptyIdIsRejected(){- var ex = Rejects(Entry("e", "lon: 35, lat: 32, type: town, founded: 1900, sources: []"));- StringAssert.Contains("'e'", ex.Message); StringAssert.Contains("sources", ex.Message);+ var ex = Rejects("- {id: '', name: N, lon: 35, lat: 32, type: town, founded: 1900, " + Src + "}\n");+ StringAssert.Contains(SettlementPlacer.DefaultFileName, ex.Message); StringAssert.Contains("id", ex.Message);}+ [Test] public void EmptyNameIsRejected() =>+ AssertNames(Rejects("- {id: nn, name: '', lon: 35, lat: 32, type: town, founded: 1900, " + Src + "}\n"), "nn", "name");+[Test]- public void NullFoundedNeedsPreModern()+ public void UnknownKeyAndBadScalarBecomeInvalidDataNamingTheFile(){- var ex = Rejects(Entry("f", "lon: 35, lat: 32, type: town, founded: null, sources: [{url: u, checked: x}]"));- StringAssert.Contains("'f'", ex.Message); StringAssert.Contains("founded", ex.Message);+ StringAssert.Contains(SettlementPlacer.DefaultFileName, Rejects(Entry("k", "lon: 35, lat: 32, type: town, founded: 1900, colour: red, " + Src)).Message);+ StringAssert.Contains(SettlementPlacer.DefaultFileName, Rejects(Entry("b", "lon: east, lat: 32, type: town, founded: 1900, " + Src)).Message);}[Test]public void RealSettlementFileParses(){- var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")), Bounds);+ var list = SettlementPlacer.Parse(File.ReadAllText(RealYamlPath), Bounds);Assert.AreEqual(25, list.Count);}- // --- MapScene (built in edit mode with the editor-made material assets) ---+}++/// <summary>MapScene, built in edit mode with the editor-made material assets. Each test runs in a fresh empty scene so it+/// never touches the runner's own camera (R4). The scene replaces the runner's untitled one (NewSceneMode.Single):+/// Unity refuses an additive new scene while an untitled scene is unsaved, which is the state batch test runs start in.</summary>+public class MapSceneTests+{+ static readonly HeightmapMeta Meta = HeightmapLoader.Load(Paths.StreamingMap).meta;+ static (double, double, double, double) Bounds => (Meta.lon0, Meta.lon1, Meta.lat0, Meta.lat1);+ static string RealYamlPath => Path.Combine(Paths.Content, "map", "settlements_1948.yaml");const string TerrainMatPath = "Assets/Materials/Terrain.mat", OverlayMatPath = "Assets/Materials/HexOverlay.mat",MarkerMatPath = "Assets/Materials/SettlementMarker.mat";+ [SetUp] public void FreshScene() => EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);++ // Replacing the scene destroys everything the test built (MapRuntimeAssets frees the runtime assets with it).+ [TearDown] public void DiscardScene() => EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+static Material Load(string path) { var m = AssetDatabase.LoadAssetAtPath<Material>(path); Assert.IsNotNull(m, path); return m; }- static (MapScene map, GameObject cam) NewMap()+ static MapScene NewMap(bool withCamera = true){- var cam = new GameObject("TestMainCamera") { tag = "MainCamera" }; cam.AddComponent<Camera>();+ if (withCamera) new GameObject("TestMainCamera") { tag = "MainCamera" }.AddComponent<Camera>();var map = new GameObject("MapScene").AddComponent<MapScene>();map.Configure(Load(TerrainMatPath), Load(OverlayMatPath), Load(MarkerMatPath));- return (map, cam);+ return map;}- // Camera.main may be a camera of the test runner's scene rather than ours, so remove every rig Build added.- static void Cleanup(MapScene map, GameObject cam)+ static int CountNamed(string name){- Object.DestroyImmediate(map.gameObject);- foreach (var rig in Object.FindObjectsByType<CameraRig>(FindObjectsSortMode.None)) Object.DestroyImmediate(rig);- Object.DestroyImmediate(cam);+ int n = 0; foreach (var t in Object.FindObjectsByType<Transform>(FindObjectsSortMode.None)) if (t.name == name) n++;+ return n;+ }++ static void AssertOneOfEach()+ {+ Assert.AreEqual(1, Object.FindObjectsByType<Terrain>(FindObjectsSortMode.None).Length, "terrains");+ Assert.AreEqual(1, Object.FindObjectsByType<Volume>(FindObjectsSortMode.None).Length, "volumes");+ Assert.AreEqual(1, CountNamed("Settlements"), "Settlements roots");+ Assert.AreEqual(1, Object.FindObjectsByType<CameraRig>(FindObjectsSortMode.None).Length, "camera rigs");}[Test]public void BuildWithoutMaterialsNamesTheMissingField(){var map = new GameObject("MapScene").AddComponent<MapScene>();- try- {- map.Configure(Load(TerrainMatPath), Load(OverlayMatPath), null);- var ex = Assert.Throws<System.InvalidOperationException>(() => map.Build());- StringAssert.Contains("markerMaterial", ex.Message);- }- finally { Object.DestroyImmediate(map.gameObject); }+ map.Configure(Load(TerrainMatPath), Load(OverlayMatPath), null);+ var ex = Assert.Throws<System.InvalidOperationException>(() => map.Build());+ StringAssert.Contains("markerMaterial", ex.Message);+ }++ [Test]+ public void BuildWithoutMainCameraThrows()+ {+ var map = NewMap(withCamera: false);+ Assert.IsNull(Camera.main);+ var ex = Assert.Throws<System.InvalidOperationException>(() => map.Build());+ Assert.AreEqual("MapScene needs a camera tagged MainCamera", ex.Message);}[Test]public void BuildTwiceLeavesOneTerrainOneSettlementsRootAndOneVolume(){- var (map, cam) = NewMap();- try+ var map = NewMap();+ map.Build(); map.Build();+ AssertOneOfEach();+ }++ [Test]+ public void RebuildByAFreshComponentStillClearsTheOldMap()+ {+ // After a domain reload a MapScene has lost any non-serialized references to what it built (R2).+ var map = NewMap(); map.Build();+ var go = map.gameObject; Object.DestroyImmediate(map);+ var fresh = go.AddComponent<MapScene>();+ fresh.Configure(Load(TerrainMatPath), Load(OverlayMatPath), Load(MarkerMatPath));+ fresh.Build();+ AssertOneOfEach();+ }++ [Test]+ public void RebuildingDoesNotLeakDepthOfFieldComponents()+ {+ var map = NewMap(); map.Build();+ int after1 = Resources.FindObjectsOfTypeAll<DepthOfField>().Length;+ map.Build(); map.Build();+ Assert.AreEqual(after1, Resources.FindObjectsOfTypeAll<DepthOfField>().Length);+ }++ [Test]+ public void EveryMarkerSitsOnItsSourcedPositionWithTheMarkerMaterial()+ {+ var map = NewMap(); map.Build();+ var marker = Load(MarkerMatPath);+ Assert.AreEqual("Universal Render Pipeline/Lit", marker.shader.name);+ Assert.AreEqual(0f, marker.GetFloat("_Smoothness"), "matte marker");++ // The frame comes from the heightmap meta, independently of the code under test (R5).+ Assert.AreEqual(Meta.lon0, map.Frame.Lon0); Assert.AreEqual(Meta.lon1, map.Frame.Lon1);+ Assert.AreEqual(Meta.lat0, map.Frame.Lat0); Assert.AreEqual(Meta.lat1, map.Frame.Lat1);+ Assert.AreEqual(Meta.width_km * 1000f, map.Frame.WidthM, 1f); Assert.AreEqual(Meta.length_km * 1000f, map.Frame.LengthM, 1f);++ var root = GameObject.Find("Settlements").transform;+ foreach (var s in SettlementPlacer.Parse(File.ReadAllText(RealYamlPath), Bounds)){- map.Build(); map.Build();- Assert.AreEqual(1, Object.FindObjectsByType<Terrain>(FindObjectsSortMode.None).Length, "terrains");- Assert.AreEqual(1, Object.FindObjectsByType<Volume>(FindObjectsSortMode.None).Length, "volumes");- int roots = 0;- foreach (var t in Object.FindObjectsByType<Transform>(FindObjectsSortMode.None)) if (t.name == "Settlements") roots++;- Assert.AreEqual(1, roots, "Settlements roots");- Assert.AreEqual(1, Object.FindObjectsByType<CameraRig>(FindObjectsSortMode.None).Length, "camera rigs"); // on Camera.main+ var box = root.Find(s.Id); Assert.IsNotNull(box, s.Id);+ var want = map.Frame.ToWorld(s.Lon, s.Lat, 0);+ Assert.AreEqual(want.x, box.position.x, 1f, s.Id + " x"); Assert.AreEqual(want.z, box.position.z, 1f, s.Id + " z");+ float baseY = box.position.y - box.lossyScale.y / 2;+ Assert.AreEqual(map.Terrain.SampleHeight(box.position), baseY, 1f, s.Id + " base y");+ Assert.AreSame(marker, box.GetComponent<Renderer>().sharedMaterial, s.Id + " material");+ Assert.IsNull(box.GetComponent<Collider>(), s.Id + " has a collider (R1)");}- finally { Cleanup(map, cam); }+ var jerusalem = root.Find("jerusalem").position;+ Assert.AreEqual((35.2256 - Meta.lon0) / (Meta.lon1 - Meta.lon0) * Meta.width_km * 1000.0, jerusalem.x, 1.0, "Jerusalem x, absolute");+ Assert.AreEqual((31.7789 - Meta.lat0) / (Meta.lat1 - Meta.lat0) * Meta.length_km * 1000.0, jerusalem.z, 1.0, "Jerusalem z, absolute");+ var telAviv = root.Find("tel_aviv").position; var haifa = root.Find("haifa").position;+ Assert.Less(telAviv.x, jerusalem.x, "Tel Aviv west of Jerusalem");+ Assert.Greater(haifa.z, telAviv.z, "Haifa north of Tel Aviv"); Assert.Greater(haifa.z, jerusalem.z, "Haifa north of Jerusalem");}[Test]- public void EveryMarkerSitsOnItsSourcedPositionWithTheMarkerMaterial()+ public void LabelsAreLightWithADarkShadowAboveTheMarkerFacingTheRig(){- var (map, cam) = NewMap();- try+ var map = NewMap(); map.Build();+ var root = GameObject.Find("Settlements").transform;+ var cam = Camera.main.transform;+ foreach (var s in SettlementPlacer.Parse(File.ReadAllText(RealYamlPath), Bounds)){- map.Build();- var marker = Load(MarkerMatPath);- Assert.AreEqual("Universal Render Pipeline/Lit", marker.shader.name);- Assert.AreEqual(0f, marker.GetFloat("_Smoothness"), "matte marker");- var root = GameObject.Find("Settlements").transform;- var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")), Bounds);- foreach (var s in list)- {- var box = root.Find(s.Id); Assert.IsNotNull(box, s.Id);- var want = map.Frame.ToWorld(s.Lon, s.Lat, 0);- Assert.AreEqual(want.x, box.position.x, 1f, s.Id + " x"); Assert.AreEqual(want.z, box.position.z, 1f, s.Id + " z");- float baseY = box.position.y - box.lossyScale.y / 2;- Assert.AreEqual(map.Terrain.SampleHeight(box.position), baseY, 1f, s.Id + " base y");- Assert.AreSame(marker, box.GetComponent<Renderer>().sharedMaterial, s.Id + " material");- }- var telAviv = root.Find("tel_aviv").position; var jerusalem = root.Find("jerusalem").position; var haifa = root.Find("haifa").position;- Assert.Less(telAviv.x, jerusalem.x, "Tel Aviv west of Jerusalem");- Assert.Greater(haifa.z, telAviv.z, "Haifa north of Tel Aviv"); Assert.Greater(haifa.z, jerusalem.z, "Haifa north of Jerusalem");+ var box = root.Find(s.Id); var label = root.Find(s.Id + "_label"); Assert.IsNotNull(label, s.Id + " label");+ var text = label.GetComponent<TextMesh>(); Assert.AreEqual(s.Name, text.text);+ Assert.Greater(Mathf.Min(text.color.r, text.color.g, text.color.b), 0.85f, s.Id + " label is light");+ Assert.AreEqual(CameraRig.Pitch, label.eulerAngles.x, 0.01f, s.Id + " label pitch");+ // The whole label sits above the marker's top in screen terms: its base is above every point of the box.+ var top = box.position + Vector3.up * box.lossyScale.y / 2;+ var farTopEdge = top + Vector3.forward * box.lossyScale.z / 2;+ Assert.Greater(Vector3.Dot(label.position - farTopEdge, cam.up), 0f, s.Id + " label base above the box's far top edge");+ var shadow = label.Find("shadow"); Assert.IsNotNull(shadow, s.Id + " shadow");+ var st = shadow.GetComponent<TextMesh>(); Assert.AreEqual(s.Name, st.text);+ Assert.Less(Mathf.Max(st.color.r, st.color.g, st.color.b), 0.2f, s.Id + " shadow is dark");+ Assert.Greater(Vector3.Dot(shadow.position - label.position, cam.forward), 0f, s.Id + " shadow behind the label");}- finally { Cleanup(map, cam); }}}diff --git a/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef b/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdefindex ef4c6c8fe..3bfb49794 100644--- a/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef+++ b/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef@@ -1 +1 @@-{ "name": "Statecraft.Tests.EditMode", "references": ["Statecraft.Game", "Unity.RenderPipelines.Core.Runtime", "UnityEngine.TestRunner", "UnityEditor.TestRunner"], "includePlatforms": ["Editor"], "overrideReferences": true, "precompiledReferences": ["nunit.framework.dll", "Statecraft.Sim.dll", "YamlDotNet.dll"], "defineConstraints": ["UNITY_INCLUDE_TESTS"] }+{ "name": "Statecraft.Tests.EditMode", "references": ["Statecraft.Game", "Unity.RenderPipelines.Core.Runtime", "Unity.RenderPipelines.Universal.Runtime", "UnityEngine.TestRunner", "UnityEditor.TestRunner"], "includePlatforms": ["Editor"], "overrideReferences": true, "precompiledReferences": ["nunit.framework.dll", "Statecraft.Sim.dll", "YamlDotNet.dll"], "defineConstraints": ["UNITY_INCLUDE_TESTS"] }diff --git a/unity/ProjectSettings/SceneTemplateSettings.json b/unity/ProjectSettings/SceneTemplateSettings.jsonnew file mode 100644index 000000000..ede5887b3--- /dev/null+++ b/unity/ProjectSettings/SceneTemplateSettings.json@@ -0,0 +1,121 @@+{+ "templatePinStates": [],+ "dependencyTypeInfos": [+ {+ "userAdded": false,+ "type": "UnityEngine.AnimationClip",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEditor.Animations.AnimatorController",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.AnimatorOverrideController",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEditor.Audio.AudioMixerController",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.ComputeShader",+ "defaultInstantiationMode": 1+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Cubemap",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.GameObject",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEditor.LightingDataAsset",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.LightingSettings",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Material",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEditor.MonoScript",+ "defaultInstantiationMode": 1+ },+ {+ "userAdded": false,+ "type": "UnityEngine.PhysicsMaterial",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.PhysicsMaterial2D",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Rendering.VolumeProfile",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEditor.SceneAsset",+ "defaultInstantiationMode": 1+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Shader",+ "defaultInstantiationMode": 1+ },+ {+ "userAdded": false,+ "type": "UnityEngine.ShaderVariantCollection",+ "defaultInstantiationMode": 1+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Texture",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Texture2D",+ "defaultInstantiationMode": 0+ },+ {+ "userAdded": false,+ "type": "UnityEngine.Timeline.TimelineAsset",+ "defaultInstantiationMode": 0+ }+ ],+ "defaultDependencyTypeInfo": {+ "userAdded": false,+ "type": "<default_scene_template_dependencies>",+ "defaultInstantiationMode": 1+ },+ "newSceneOverride": 0+}\ No newline at end of file