Unity Debug Console Commands & Cheats
Jahro's Unity console commands system lets you execute debug actions and cheats directly in your Unity builds without rebuilding. You can trigger methods, pass parameters, and see results immediately through either a text-based console or visual interface. This Unity debug console is perfect for runtime testing and game development.
Unity debug console vs default console
| Feature | Unity Default Console | Jahro Debug Console |
|---|---|---|
| Runtime Commands | Not available | Full command system |
| Mobile Access | Editor only | Works on device |
| Visual Interface | Text only | Text + Visual modes |
| Team Sharing | Not available | Shareable commands |
| Custom Commands | Not supported | Full customization |
| Parameter Support | Not available | Type-safe parameters |
Why Unity console commands matter
Unity console commands eliminate the need to build custom debug UI or modify your game code for testing. Instead of adding temporary buttons or creating special debug builds, you can execute any method directly in your live game. This is especially valuable for testing features, adjusting game balance, or debugging issues that only appear in specific scenarios. Commands work seamlessly with Watcher for variable monitoring and snapshots for session capture.
Create custom Unity console commands
Unity console commands in Jahro are created using the [JahroCommand] attribute:
using JahroConsole;
using UnityEngine;
public class GameDebug
{
[JahroCommand("reset-game", "Game", "Reset the current game state")]
public static void ResetGame()
{
// Reset game logic here
}
[JahroCommand("spawn-enemy", "Spawning", "Spawn an enemy at position")]
public static void SpawnEnemy(Vector3 position)
{
// Spawn enemy logic
}
}Unity cheat console for testing
Unity cheat console commands are perfect for QA testing and game balance:
public class Cheats : MonoBehaviour
{
[JahroCommand("add-gold", "Cheats", "Add gold to player")]
public void AddGold(int amount) => Player.Wallet.Add(amount);
[JahroCommand("tp", "Cheats", "Teleport player")]
public void Teleport(Vector3 position) => Player.Transform.position = position;
[JahroCommand("set-difficulty", "Cheats", "Set game difficulty")]
public void SetDifficulty(Difficulty level) => Game.SetDifficulty(level);
}Creating commands
Attribute-based commands
The simplest way to create commands is by adding the JahroCommand attribute to your methods. Jahro automatically discovers these methods and makes them available in both text mode and visual mode.
using JahroConsole;
using UnityEngine;
public class GameDebug
{
[JahroCommand("reset-game", "Game", "Reset the current game state")]
public static void ResetGame()
{
// Reset game logic here
}
// Name inferred from method name: "Ping"
[JahroCommand]
public static void Ping()
{
Debug.Log("pong");
}
// With group only
[JahroCommand("spawn-enemy", "Spawning")]
public static void SpawnEnemy() { }
}When you omit the name parameter, Jahro uses the method name. The group parameter defaults to "Default" if not specified, and spaces are automatically removed from command names.
Instance commands
For commands that need to work with specific game objects, register the object with Jahro so it can access instance methods and properties. This also enables Watcher functionality for the same objects.
public class GameRuntime : MonoBehaviour
{
void OnEnable()
{
Jahro.RegisterObject(this);
}
void OnDisable()
{
Jahro.UnregisterObject(this);
}
[JahroCommand("set-difficulty", "Game", "Set difficulty by enum")]
public void SetDifficulty(Difficulty level) { /* ... */ }
[JahroWatch("Player HP", "Vitals", "Current hit points")]
public int playerHp;
}The RegisterObject method scans for both JahroCommand methods and JahroWatch fields/properties on that instance, making them available for runtime use.
Dynamic commands
You can also register commands programmatically using delegates, which is useful for creating commands at runtime or integrating with existing systems.
// No parameters
Jahro.RegisterCommand("clear-cache", "Maintenance", "Clear local cache", () =>
{
// Clear cache logic
});
// With parameters (generic overloads)
Jahro.RegisterCommand<int>("add-lives", "Cheats", "Add player lives", (amount) =>
{
// Add lives logic
});Jahro provides overloads for Action, Action<T>, Action<T1,T2>, and Action<T1,T2,T3> to handle different parameter combinations.
Running commands
Text mode
In text mode, you type commands directly into the console. Jahro provides autocomplete to help with command names and parameters.

Examples:
reset-gameset-difficulty Hardtp 10 2.5 -7(Vector3 coordinates)batch-set 1 2 3 4(array parameters)
The console automatically converts string parameters to the appropriate types and handles overload resolution when multiple method signatures exist.
Visual mode
Visual mode provides a graphical interface where you can browse commands by group, see descriptions, and fill parameters using form inputs. This is especially useful for complex commands with multiple parameters or when you want to explore available functionality.

As you can imagine, Visual Mode is very handy on mobile devices. Just tap a button and the command will be executed.
Parameter handling
Jahro automatically converts string parameters to your method parameters using intelligent type mapping. The system supports primitives like int, float, bool, and string, as well as Unity types like Vector2, Vector3, and enums.

When multiple method signatures exist, Jahro chooses the best match based on parameter count and conversion success. If no match is found, you'll see a helpful error message listing the accepted signatures.
Command organization
Organize your commands using descriptive names and logical groups. Use kebab-case for command names (like spawn-enemy) and group related commands together (like "Cheats", "Spawning", or "Game").
[JahroCommand("spawn-enemy", "Spawning", "Spawn an enemy at a position")]
public void SpawnEnemy(Vector3 position) { /* ... */ }
[JahroCommand("spawn-enemy", "Spawning", "Spawn a number of enemies")]
public void SpawnEnemy(int count) { /* ... */ } // Overload by signatureReturn values
Commands can return strings that are automatically displayed in the console, making them useful for querying game state.
[JahroCommand("GetPosition")]
public static string GetPlayerPosition()
{
return $"X: {Player.Position.x}, Y: {Player.Position.y}";
}Best practices
Keep command names short and descriptive, use logical grouping, and prefer simple parameter types for text mode compatibility. For instance methods, always register and unregister objects in OnEnable and OnDisable to prevent memory leaks.
Write clear descriptions for visual mode users, and keep command bodies lightweight by calling into your existing systems and services rather than implementing complex logic directly in commands.
Example implementations
Cheats system
public enum Difficulty { Easy, Normal, Hard }
public class Cheats : MonoBehaviour
{
void OnEnable() => Jahro.RegisterObject(this);
void OnDisable() => Jahro.UnregisterObject(this);
[JahroCommand("add-gold", "Cheats", "Add gold to player")]
public void AddGold(int amount) => Player.Wallet.Add(amount);
[JahroCommand("tp", "Cheats", "Teleport player")]
public void Teleport(Vector3 position) => Player.Transform.position = position;
[JahroCommand("set-difficulty", "Cheats", "Set game difficulty")]
public void SetDifficulty(Difficulty level) => Game.SetDifficulty(level);
}Dynamic registration
public class Boot : MonoBehaviour
{
void Start()
{
Jahro.RegisterCommand("gc-collect", "Maintenance", "Force GC", () =>
{
System.GC.Collect();
});
Jahro.RegisterCommand<int, float>("set-mult", "Tuning", "Set damage mult and cooldown", (damageMult, cooldown) =>
{
Tuning.DamageMultiplier = damageMult;
Tuning.Cooldown = cooldown;
});
}
}Related Unity debugging features
Explore more Jahro features to build a complete debugging workflow:
- Unity Runtime Inspector - Track variables live without debug logs
- Unity Log Viewer - View and filter Unity logs in your game view
- Unity Snapshot System - Capture and share complete debugging sessions
- Unity Mobile Debugging - Complete mobile debugging setup
Next Steps
For advanced command usage, check out the API Reference and learn about Jahro Settings configuration.
Ready to start using console commands? Get started with Jahro and begin debugging in minutes.