Files
Barrack-Unity/AGENTS.md
T

4.5 KiB

AGENTS

This file gives AI coding agents the minimum project context needed to work safely and productively in this Unity repository.

Project Snapshot

First Checks Before Editing

  1. Read ProjectSettings/ProjectVersion.txt and target that editor version.
  2. Read Packages/manifest.json for package-provided APIs before introducing new types.
  3. Do not edit generated folders or files listed in .gitignore.

Linux Build and Test Commands

Set a Unity executable path first (prefer your local Unity Hub install):

UNITY="${UNITY:-/home/$USER/Unity/Hub/Editor/6000.5.6f1/Editor/Unity}"
PROJECT="/home/mse/Documentos/Unity Projects/Barrack Unity"

Open project:

"$UNITY" -projectPath "$PROJECT"

Batch build (Linux player):

"$UNITY" \
  -batchmode -quit \
  -projectPath "$PROJECT" \
  -buildTarget StandaloneLinux64 \
  -buildLinux64Player "$PROJECT/Build/Barrack.x86_64" \
  -logFile "$PROJECT/Logs/build.log"

EditMode tests:

"$UNITY" \
  -batchmode -quit \
  -projectPath "$PROJECT" \
  -runTests -testPlatform EditMode \
  -testResults "$PROJECT/test-results-editmode.xml" \
  -logFile "$PROJECT/Logs/tests-editmode.log"

PlayMode tests:

"$UNITY" \
  -batchmode -quit \
  -projectPath "$PROJECT" \
  -runTests -testPlatform PlayMode \
  -testResults "$PROJECT/test-results-playmode.xml" \
  -logFile "$PROJECT/Logs/tests-playmode.log"

Notes:

  • If no tests exist yet, test runs may complete with zero tests.
  • Do not treat Assembly-CSharp.csproj as source of truth; Unity regenerates it.

Key Code Areas

Project Conventions

  • One class per file; class name matches file name.
  • No namespaces in project scripts.
  • PascalCase for classes/methods; camelCase for fields/locals.
  • Many Inspector-assigned dependencies are public fields.
  • Lifecycle and coroutine patterns follow standard Unity Start, Update, FixedUpdate, and IEnumerator usage.
  • Prefer existing Input System patterns over legacy Input APIs.

Unity Safety Rules

Common Failure Patterns (Seen In Prior Sessions)

  • Missing Inspector references leading to NullReferenceException at runtime.
  • Animator transition or trigger mismatches causing entities to remain in wrong states.
  • Type/namespace mismatches when using package APIs.

When adding fields or animator parameters, include defensive null checks and keep names synchronized with scene/prefab/controller data.

Useful References