-
Notifications
You must be signed in to change notification settings - Fork 7
Features Editor Tools Unity Method Analyzer
Detect C# inheritance issues and Unity lifecycle errors across your entire codebase.
The Unity Method Analyzer scans your project's C# files and identifies common mistakes in method overrides, Unity lifecycle methods, and inheritance patterns—before they cause runtime bugs. Use it during development to catch silent failures, missing base calls, and signature mismatches.
- Overview
- Getting Started
- What It Detects
- Using the Analyzer
- Filtering Results
- Exporting Reports
- Suppressing Warnings
- Best Practices

The Unity Method Analyzer provides:
- Static code analysis without needing Roslyn or external tools
- Parallel scanning of thousands of files in seconds
- Issue categorization by severity and type
- One-click navigation to problematic code
- Export capabilities for CI/CD integration or team review
- Flexible filtering to focus on what matters
Common issues detected:
| Issue Type | Example |
|---|---|
Missing override keyword |
Hiding base method instead of overriding |
| Wrong method signature |
OnCollisionEnter(Collider c) instead of OnCollisionEnter(Collision c)
|
| Shadowed lifecycle methods | Both base and derived class have private void Start()
|
| Return type mismatches |
void Start() vs IEnumerator Start() in inheritance chain |
| Static lifecycle methods |
static void Awake() won't be called by Unity |
Menu: Tools > Wallstop Studios > Unity Helpers > Unity Method Analyzer

- Open the analyzer from the menu
- Add source directories — By default, scans from the project root
- Click "Analyze Code" — Wait for the progress bar to complete
- Review results — Issues appear grouped by file, severity, or category

The analyzer groups issues into three categories:
Problems with Unity's magic methods (Start, Update, OnCollisionEnter, etc.):
// ❌ WRONG: Unexpected parameters - Unity won't call this
void Update(float deltaTime) // Update takes no parameters
{
Move(deltaTime);
}
// ✅ CORRECT: Proper signature
void Update()
{
Move(Time.deltaTime);
}// ❌ WRONG: Static lifecycle method - Unity won't call it
static void Awake()
{
Initialize();
}
// ✅ CORRECT: Instance method
void Awake()
{
Initialize();
}// ⚠️ SHADOWING: Both base and derived have private Start()
public class BaseEnemy : MonoBehaviour
{
private void Start() { BaseInit(); } // Called for BaseEnemy instances
}
public class Boss : BaseEnemy
{
private void Start() { BossInit(); } // Only this is called for Boss instances
}
// ✅ BETTER: Use virtual/override pattern
public class BaseEnemy : MonoBehaviour
{
protected virtual void Start() { BaseInit(); }
}
public class Boss : BaseEnemy
{
protected override void Start()
{
base.Start(); // Calls BaseInit()
BossInit();
}
}Problems when extending Unity base classes:
public class GameManager : MonoBehaviour
{
// ❌ WRONG: Using 'new' hides the base method
public new void Awake()
{
Initialize();
}
// ✅ CORRECT: Use virtual/override pattern if base is virtual
// Or just declare normally for MonoBehaviour lifecycle
private void Awake()
{
Initialize();
}
}Problems in your own class hierarchies:
public class BaseEnemy : MonoBehaviour
{
public virtual void TakeDamage(int amount) { }
}
public class Boss : BaseEnemy
{
// ❌ WRONG: Missing 'override' keyword - hides base method
public void TakeDamage(int amount)
{
// This won't be called polymorphically!
}
// ✅ CORRECT: Properly override
public override void TakeDamage(int amount)
{
base.TakeDamage(amount);
// Boss-specific logic
}
}| Severity | Description | Example |
|---|---|---|
| Critical | Will cause runtime failures or silent bugs | Missing override hiding virtual method |
| High | Likely unintended behavior | Wrong Unity lifecycle signature |
| Medium | Potential issues worth reviewing | Suspicious method hiding |
| Low | Style or minor concerns | Non-standard access modifiers |
| Info | Informational notes | Detected patterns for review |
Configure which directories to scan:

- Click "+" to add a new directory
- Click "..." to browse for a different path
- Click "-" to remove a directory
- Red paths indicate directories that don't exist
Tip: Add only relevant directories (e.g., Assets/Scripts) to speed up analysis.
The results are displayed in a hierarchical tree view:

- Expand/collapse groups with the arrow
- Single-click an issue to see details in the panel below
- Double-click to open the file at the exact line number
- Right-click for context menu options
When you select an issue, the detail panel shows:

- File path and line number
- Class and method names
- Issue type and severity
- Detailed description of the problem
- Recommended fix with specific guidance
- Base class information when relevant
Organize results by:
- File — Group issues by source file (default)
- Severity — Group by Critical/High/Medium/Low/Info
- Category — Group by Unity Lifecycle/Unity Inheritance/General

Focus on specific severity levels:

Focus on specific issue categories:
- All — Show everything
- Unity Lifecycle — Only lifecycle method issues
- Unity Inheritance — Only Unity class inheritance issues
- General Inheritance — Only custom class inheritance issues
Free-text search across all issue fields:

Search matches against:
- File paths
- Class names
- Method names
- Issue descriptions
Click "Export ▾" to access export options:

- Copy Selected as JSON — Copy the selected issue
- Copy Selected as Markdown — Copy the selected issue as readable text
- Copy All as JSON — Copy all filtered issues
- Copy All as Markdown — Copy all filtered issues as readable text
- Save as JSON... — Export to a JSON file for CI/CD integration
- Save as Markdown... — Export to a Markdown file for documentation or review
{
"analysisDate": "2024-01-15T10:30:00Z",
"totalIssues": 12,
"issues": [
{
"filePath": "Assets/Scripts/Player/PlayerController.cs",
"className": "PlayerController",
"methodName": "OnCollisionEnter",
"issueType": "Unity Lifecycle Signature Mismatch",
"description": "Method 'OnCollisionEnter' has wrong parameter type",
"severity": "High",
"recommendedFix": "Change parameter from 'Collider' to 'Collision'",
"lineNumber": 42,
"category": "UnityLifecycle"
}
]
}# Unity Method Analyzer Report
Generated: 2024-01-15 10:30:00
Total Issues: 12
## Critical (2)
### PlayerController.cs:42
**Class:** PlayerController
**Method:** OnCollisionEnter
**Issue:** Unity Lifecycle Signature Mismatch
**Fix:** Change parameter from 'Collider' to 'Collision'For test code or intentional patterns, use [SuppressAnalyzer]:
using WallstopStudios.UnityHelpers.Tests.Core;
// Suppress entire class
[SuppressAnalyzer("Test fixture for analyzer validation")]
public class TestClassWithIntentionalIssues : BaseClass
{
public void HiddenMethod() { } // Won't trigger warning
}
// Or suppress specific methods
public class TestClass : BaseClass
{
[SuppressAnalyzer("Testing method hiding detection")]
public new void VirtualMethod() { } // Won't trigger warning
}Note: [SuppressAnalyzer] is only available in test assemblies. Production code should fix issues rather than suppress them.
- Before committing — Catch issues early
- During code review — Export reports for team review
- In CI/CD — Use JSON export for automated checks
- After refactoring — Verify inheritance chains remain correct
-
Run full scan on your
Assets/Scriptsfolder - Filter by Critical/High severity first
- Fix issues starting with Critical
- Re-scan to verify fixes
- Export report for documentation
- Scan specific directories rather than the entire project
- Use filters to focus on relevant issues
- Close other editor windows during large scans
- Exclude generated code directories
Export JSON reports and parse them in your build pipeline:
# Example: Fail build if critical issues exist
unity -batchmode -projectPath . -executeMethod AnalyzerRunner.RunAndExport
cat analyzer-report.json | jq '.issues | map(select(.severity == "Critical")) | length'| Feature | Description |
|---|---|
| Menu Location | Tools > Wallstop Studios > Unity Helpers > Unity Method Analyzer |
| Issue Categories | Unity Lifecycle, Unity Inheritance, General Inheritance |
| Severity Levels | Critical, High, Medium, Low, Info |
| Export Formats | JSON, Markdown |
| Suppression |
[SuppressAnalyzer] attribute (test assemblies only) |
📦 Unity Helpers | 📖 Documentation | 🐛 Issues | 📜 MIT License
- Inspector Button
- Inspector Conditional Display
- Inspector Grouping Attributes
- Inspector Inline Editor
- Inspector Overview
- Inspector Selection Attributes
- Inspector Settings
- Inspector Validation Attributes
- Utility Components
- Visual Components
- Data Structures
- Helper Utilities
- Math And Extensions
- Random Generators
- Reflection Helpers
- Singletons