tea-x-random/unity-game-skills / skills/unity-scene-composition
unity-scene-composition
VerifiedDefine and enforce Unity scene composition before asset generation or assembly. Use for composition.yaml, camera projection/yaw/pitch/lens/framing, visual layers, focal path, negative space, big-medium-small rhythm, prop density/distribution, color zones, occlusion budgets, contact shadows, BeautyCell/golden screens, registry asset placement, or scenes that are mechanically correct but visually weak. Covers sprite-on-3D/2.5D pixel density, Y-axis billboarding, feet pivots, blob shadows and quarter-view framing; diagnoses pasted-on, floating or mismatched-chunkiness sprites; and runs deterministic scene measurements plus visual critique. Pair with unity-game-layout, unity-asset-pipeline, unity-art-direction, unity-graphics and unity-ui-designer.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.6 KB |
| agents/openai.yaml | config | 213 B |
| references/composition-template.yaml | config | 4.5 KB |
| references/scene-measurement.md | markdown | 4.4 KB |
| references/screenshot-acceptance.md | markdown | 3.3 KB |
references/scene-measurement.md
View on GitHub# Deterministic scene measurement (MCP)
How to compute the `measured_acceptance` gates from live Unity scene data. Run via `unity-mcp-bridge` `execute_code`, or wrap in a `[MenuItem]` editor script for crash-safe re-runs. Output is JSON — compare it against `composition.yaml` budgets agent-side and record it with the QA evidence.
## Step 1 — build the registry map (agent-side)
Parse `Assets/<Game>/Art/Approved/registry.yaml` + each `asset-contract.yaml` into a map:
`prefab/asset name → { density_cost, visual_weight, composition.layer, role, target_screen_height_percent, camera_contract }`.
## Step 2 — walk visible renderers (C# via MCP)
```csharp
using System.Text;
using UnityEngine;
var cam = Camera.main;
var planes = GeometryUtility.CalculateFrustumPlanes(cam);
var sb = new StringBuilder();
sb.Append("{\"camera\":{\"orthographic\":" + (cam.orthographic ? "true" : "false")
+ ",\"orthographic_size\":" + cam.orthographicSize.ToString("F2")
+ ",\"yaw\":" + cam.transform.eulerAngles.y.ToString("F1")
+ ",\"pitch\":" + cam.transform.eulerAngles.x.ToString("F1") + "},\"renderers\":[");
bool first = true;
foreach (var r in Object.FindObjectsByType<Renderer>(FindObjectsSortMode.None))
{
if (!r.enabled || !GeometryUtility.TestPlanesAABB(planes, r.bounds)) continue;
var b = r.bounds;
// viewport-space AABB from the 8 bounds corners
float minX = 1f, maxX = 0f, minY = 1f, maxY = 0f;
for (int i = 0; i < 8; i++)
{
var c = b.center + Vector3.Scale(b.extents,
new Vector3((i & 1) == 0 ? -1 : 1, (i & 2) == 0 ? -1 : 1, (i & 4) == 0 ? -1 : 1));
var v = cam.WorldToViewportPoint(c);
if (v.z < 0) continue; // behind camera
minX = Mathf.Min(minX, Mathf.Clamp01(v.x)); maxX = Mathf.Max(maxX, Mathf.Clamp01(v.x));
minY = Mathf.Min(minY, Mathf.Clamp01(v.y)); maxY = Mathf.Max(maxY, Mathf.Clamp01(v.y));
}
if (!first) sb.Append(",");
first = false;
sb.Append("{\"name\":\"" + r.gameObject.name + "\",\"root\":\"" + r.transform.root.name
+ "\",\"screen_height_pct\":" + ((maxY - minY) * 100f).ToString("F1")
+ ",\"viewport_rect\":[" + minX.ToString("F3") + "," + minY.ToString("F3") + ","
+ maxX.ToString("F3") + "," + maxY.ToString("F3") + "]}");
}
sb.Append("]}");
Debug.Log(sb.ToString());
```
## Step 3 — join and gate (agent-side)
- **no_unapproved_assets:** every renderer's name/root must resolve to a registry entry or a ledger-flagged placeholder. Unresolved visible renderer = FAIL.
- **density_within_budget:** sum resolved `density_cost` ≤ `density_budget.max_density_cost_per_screen`; count interesting objects and distinct families vs their caps.
- **screen_heights_within_role_ranges:** each renderer's `screen_height_pct` inside `shape_rhythm.target_screen_height_percent[role]`.
- **occlusion_within_budget:** for renderers whose contract layer is `foreground`, sum viewport-rect area intersecting the gameplay area (viewport minus UI margins) ≤ `occlusion_budget.gameplay_area_max_percent`. (Summed AABBs ignore overlap — conservative, which is the right direction for a gate.)
- **camera_contracts_match:** the reported camera block equals `camera_profile` (projection/yaw/pitch/ortho size within 0.5 tolerance); each visible asset's `camera_contract` matches or is marked UI/background.
## Step 4 — one-pixel-density check (sprite/2.5D scenes)
```csharp
using UnityEngine;
// Set groundName before running; target PPU comes from art-spec craft.pixels_per_unit.
var groundName = "Ground";
var mr = GameObject.Find(groundName).GetComponent<Renderer>();
var mat = mr.sharedMaterial;
var tex = mat.mainTexture;
float texelsPerUnit = tex.width * mat.mainTextureScale.x / mr.bounds.size.x;
Debug.Log("{\"ground\":\"" + groundName + "\",\"texels_per_unit\":" + texelsPerUnit.ToString("F1")
+ ",\"filter\":\"" + tex.filterMode + "\",\"mipmaps\":" + (tex.mipmapCount > 1 ? "true" : "false") + "}");
```
Gate: `|texels_per_unit − craft.pixels_per_unit| / PPU ≤ pixel_density.texel_tolerance_percent`; pixel track additionally requires `filter == Point` and no mipmaps on ground AND sprites, and the `pixel_density.light_model` (unlit sprites ⇒ unlit ground).
## Recording
Store the raw JSON from steps 2/4 plus the per-gate pass/fail verdict alongside the screenshot in the BeautyCell/scene QA artifact. These numbers are the gate; the VLM scene critique (screenshot-acceptance.md Pass 2) never overrides them.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |