Editor Tools and Tests

In short

All editor tooling lives in Assets/_Project/Editor/ (assembly HomeRunDerby.Editor, namespace HomeRunDerby.EditorTools) under the Tools > Home Run Derby menu. Tests are plain static Run() methods, not Unity Test Framework tests: they log PASSED or FAILED with the failures, and in batch mode exit with code 0 or 1.

How it works

Every menu item

Menu pathClass.MethodWhat it does
Tools > Home Run Derby > Run Run Structure TestRunStructureTest.RunTest (below).
Tools > Home Run Derby > Run Progression XP TestProgressionXpTest.RunTest (below).
Tools > Home Run Derby > Run Ball Effect TestBallEffectTest.RunTest (below).
Tools > Home Run Derby > Run Batting Model TestBattingModelTest.RunTest (below).
Tools > Home Run Derby > Run Hit Tally TestHitTallyTest.RunTest (below).
Tools > Home Run Derby > Run Scoreboard Smash TestScoreboardSmashTest.RunTest (below).
Tools > Home Run Derby > Smash Scoreboard (Play mode)ScoreboardSmashTest.SmashNowRaises ScoreboardHit at a random spot on the current board. Greyed out outside Play mode.
Tools > Home Run Derby > Preview Match IntroMatchIntroTools.PreviewPlays the match intro on the current run’s inning (or the first park with your batter) at 1x. Play mode only (otherwise a “Press Play first” dialog). (Cutscenes)
Tools > Home Run Derby > Preview Match Intro (Quarter Speed)MatchIntroTools.PreviewSlowThe same at 0.25x.
Tools > Home Run Derby > Preview Outro: Boss Down / Victory / DefeatMatchIntroTools.PreviewBossDown, PreviewVictory, PreviewDefeatPlays that end-of-game cutscene at 1x. Play mode only.
Tools > Home Run Derby > Net > Run Co-op Rules TestCoopRulesTest.RunTest (below).
Tools > Home Run Derby > Net > Run Local Transport Self-TestNetSelfTest.RunTest (below).
Tools > Home Run Derby > Net > Run Session TestNetSessionTest.RunTest (below).
Tools > Home Run Derby > Net > Run Spectate Feed TestSpectateFeedTest.RunTest (below).
Tools > Home Run Derby > Net > Run Match Intro TestMatchIntroTest.RunTest (below). Under Net although it tests mostly offline code.
Tools > Home Run Derby > Net > Run Outro TestOutroTest.RunTest (below). Also under Net.
Tools > Home Run Derby > Export Default Content To AssetsContentExporter.ExportWrites DefaultContent to assets under Assets/_Project/Content/<Kind>/ and Resources/ContentDatabase.asset (asks before overwriting). The game then loads that asset instead of code.
Tools > Home Run Derby > Delete Save FileContentExporter.DeleteSaveSaveSystem.Delete(): removes save.json and run.json with their backups.
Tools > Home Run Derby > Generate Fit Profile For BatterFitProfileTools.GenerateForBatterMeasures the library batter and writes its CharacterFitProfile (Fit Mode).
Tools > Home Run Derby > Bake Park DressingParkDressingEditor.BakeAllCode layouts to editable prefabs (Ballpark Building).
Tools > Home Run Derby > Set Up URPUrpSetup.RunCreates / assigns the URP assets, converts Standard materials (Rendering).
Tools > Home Run Derby > Steam > Enable SteamSteamSetup.EnableChecks the Steam DLLs, writes steam_appid.txt, adds HOMERUNDERBY_STEAM (Build and Release).
Tools > Home Run Derby > Steam > Disable SteamSteamSetup.DisableRemoves the define.
Tools > Home Run Derby > Build > Windows Player (zip)BuildPlayer.BuildWindowsZipBuilds and zips the Windows player (Build and Release).

Not on the menu: SkyShaderInclude (runs on Editor load, keeps Skybox/Procedural in builds) and ParkDressingEditor (the custom inspector for ParkDressing).

Every self-test

TestChecks
RunStructureTest9 innings with bosses in 3, 6, 9 and a final boss in 9; the same seed gives the same innings; a park’s own boss pitches the last inning; goals per map and difficulty; the unlock order (Normal, Medium, Hard; Medium opens the next map); the dev map tools; the insta-home-run swing clears every park’s wall; ResetUpgrades; coins and outs per inning; the co-op StartRun message carries the map. Uses DefaultContent and an in-memory save.
ProgressionXpTest (#37)XP curves and caps (account level 2 at 100 XP, level 10 at 3600; character level 2 at 300, 5 at 1500, 10 at 4500); run XP; batter perks at levels 2, 5, 10 add up and are included in runs; cosmetics and batters wait for their account level; call signs; what AwardXp reports; a save from before levels loads at level 1. Uses DefaultContent and an in-memory save.
BallEffectTestAnti-Gravity curve rises; Sticky arrives on time but hangs late; Ghost fades out and back in; boss and park balls stack; Wiffle swerves back onto its spot; gusts (Headwind / Tailwind) arrive on time but change pace; decoys come 1 in 4, ride along then split, never shift the pitches and travel in the pitch message; The Phantom is Midnight’s final boss and every park has its own boss; pitches arc, curveballs and changeups loop sideways; pitchers lean on the special-ball pitches; boss balls describe their odds; Midnight’s Ghost is any pitch 1 in 12; only the named pitches get the ball; special balls never shift the pitches; Super Fast is faster; the chance is roughly right; the pitch message carries the ball; Describe reads well.
BattingModelTest (#46)The Mario-style batting model (SwingResolver, HitTables, HitPhysics): contact zones along the bat and how Contact sizes them, GREEN and the replay rule, exit velocity inside each zone’s range, the launch odds and what W / S do to them, the held A / D aim, the curve’s direction and fade, a ball that hooks foul is foul, a missing pitch or batter is fine. Seeded, so every run is the same. Uses DefaultContent.Build(). See Batting Explained.
HitTallyTest (#42)The live hit counter against the real physics and scoring on every park over a sweep of swings: feet never go down and land on the scored distance; events in time order; a home run clears the wall once before landing; the earned target fires; the score stack ends exactly on ScoreCalculator.Score (GREEN and HR multipliers too, and for a spectator); outs score nothing; the big-moment rule; the counter’s phases; the tracer shot keeps the whole arc in a 16:9 frame; the flight camera starts on the batting view, keeps the ball in frame, stays out of the ground and stands and stops short of the wall; slow motion only on big moments; every TEST HITS kind found on a park really makes that hit. See Hit Show.
MatchIntroTest (#40)The match intro against the real data on every park and pitcher: the card lists every special ball and bonus target with the HUD’s payout and a worth that matches scoring; arsenal shares add up; a pitcher’s debuff shows as a red arrow; the beat script for 1 to 4 players; the CutsceneRunner (reading stops wait for a click, fast-forward, wipes cut at their midpoint); every camera shot finite, inside the far plane and above the stands, and the walk-up lands on the batting view; the easing curves; the co-op IntroGate and its message. See Cutscenes.
OutroTest (#40)The end-of-game cutscenes: beat scripts for BOSS DOWN, victory (with and without a final boss) and defeat; the line score adds up to the run’s total and the boss bonus matches the run config; the replay follows the winning hit’s path and keeps the ball in frame; every outro shot finite, inside the far plane and above the stands on every park; the pitcher’s fall.
ScoreboardSmashTestFor every park and practice park: a monster home run smashes in and drops in front; a ball 20 deg wide flies past; an ordinary 106 mph / 28 deg home run falls short (smashes on the practice map). Logs the softest hit that reaches each board. Uses ContentDatabase.LoadOrDefault.
CoopRulesTestCoopRules: pool size, opener rotation, turns alternate on outs, clearing ends the round mid-turn, an empty pool fails the round, a drop mid-turn passes without an out, a dropped player is skipped later, everyone leaving, the second life, a wrong batter is rejected.
NetSelfTestLocalTransport in-process on port 7799: a host and two clients connect, get peer ids 1 and 2, a burst of 50 reliable messages arrives once each and in order, reliable and unreliable broadcasts arrive, a client leave and a host leave are seen.
NetSessionTestNetSession over LocalTransport on port 7811: three nodes join, all see the same roster with unique names, a batter change reaches everyone, a client on another build is refused, START reaches all with the same seed and order, a leaving client shrinks the roster, the host leaving ends the others.
SpectateFeedTestSpectateFeed: the offset is the smallest delay plus the buffer; poses interpolate and hold at the ends; out-of-order poses are sorted; events come due on the delayed clock; the offset relaxes when the delay grows; the spectate messages round-trip, including the hit’s zone, held aim, curve and added gravity (#46), so watchers fly the same path.

Running them

  • In the Editor: pick the menu item. Results go to the Console (PASSED, or FAILED (n) with one error line per failure). No test needs Play mode; the Preview and Smash Scoreboard items do.
  • Headless (Unity Editor closed, from the repo root): the command written in each test’s comment is
unity run . -- -executeMethod HomeRunDerby.EditorTools.RunStructureTest.Run

Swap in ProgressionXpTest, BallEffectTest, BattingModelTest, HitTallyTest, ScoreboardSmashTest, CoopRulesTest, NetSelfTest, NetSessionTest, SpectateFeedTest, MatchIntroTest or OutroTest. In batch mode each test calls EditorApplication.Exit(0) on pass and Exit(1) on failure. UrpSetup.Run does not exit by itself; its comment adds -quit.

  • Compile check: running any of these headless first compiles both assemblies, so a pass also proves the project compiles. See Testing and Unity Setup.

Numbers

WhatValueWhere to tune
NetSelfTest port7799NetSelfTest.Port
NetSessionTest port7811NetSessionTest.Port
CoopRulesTest solo outs7CoopRulesTest.SoloOuts

In the code

FileWhat it does
Editor/HomeRunDerby.Editor.asmdefEditor-only assembly referencing HomeRunDerby and URP.
Editor/*Test.csThe twelve tests.
Editor/MatchIntroTools.csThe five Preview menu items.
Editor/ContentExporter.cs, FitProfileTools.cs, ParkDressingTools.cs, UrpSetup.cs, SkyShaderInclude.cs, SteamSetup.cs, BuildPlayer.csTools.

Gotchas

Export Default Content skips some lists

ContentExporter.Export saves run config, pitch types, pitchers, ballparks, upgrades, synergies, batters and cosmetics as assets, but not callSigns or practiceParks. Those objects are never saved as assets, so the exported database’s references to them will not survive a reload.

  • The network tests open real UDP ports on localhost; another process on 7799 or 7811 makes them fail.
  • Tests never touch the real save (MetaProgression(..., persist: false)), except Delete Save File, which is meant to.
  • com.unity.test-framework is installed but no tests use it.
  • HitTallyTest, MatchIntroTest, OutroTest and ScoreboardSmashTest use ContentDatabase.LoadOrDefault() (the exported asset if one exists); BattingModelTest, RunStructureTest and ProgressionXpTest use DefaultContent.Build().