Commands/Cheats
Jahro lets you execute custom commands (cheats) directly inside Unity Game View.
Run Commands Visually or with Text Input
You can trigger commands in two ways:
- Visual Mode - Click buttons, enter parameters with ease.
- Text Mode - Type commands manually with autocomplete for method names and parameters.
What Can You Do with Commands?
- Modify game state (unlock levels, give items, change variables)
- Trigger events (spawn enemies, reset game)
- Retrieve data (player position, debug values)
Basic Command Setup
Use the [JahroCommand]
attribute to register a method as a command. By default, the method name is used as the command name.
[JahroCommand]
public static void MyCommand()
{
Debug.Log("Hello, Jahro!");
}
using JahroConsole;
public class PlayerManager
{
[JahroCommand(name = "Give Coins", group = "Player", description = "Adds coins to the player")]
public static void AddCoins(int amount)
{
Player.Coins += amount;
}
}
Parameters
Jahro supports various parameter types:
[JahroCommand("Spawn Enemy")]
public static void SpawnEnemy(string type, int count)
{
EnemySpawner.Spawn(type, count);
}
Supported Parameter Types
- int, float, string
- bool (checkbox in Visual Mode)
- Enums (dropdown in Visual Mode)
- Vector2, Vector3, Quaternion
Static vs Non-Static Methods
- Static Methods - Available globally, no setup needed.
- Non-Static Methods - Require an instance of the object.
For non-static methods, you must register the object:
Jahro.RegisterObject(this);
This allows Jahro to find the command instances.
public class Player : MonoBehaviour
{
private void Start()
{
Jahro.RegisterObject(this);
}
[JahroCommand]
public void ResetPlayer()
{
health = 100;
}
}
Now, calling ResetPlayer will only affect the active instance of Player.
➡ Use Jahro.UnregisterObject(this);
when the object is destroyed.
Return Results
Commands can return string values. Strings will be printed to Jahro console.
[JahroCommand("GetPosition")]
public static string GetPlayerPosition()
{
return $"X: {Player.Position.x}, Y: {Player.Position.y}";
}
Method Overloading
Jahro allows overloaded methods, choosing the right version based on parameters:
[JahroCommand]
public static void SpawnEnemy()
{
Enemy.Spawn(Vector3.zero);
}
[JahroCommand]
public static void SpawnEnemy(Vector3 position)
{
Enemy.Spawn(position);
}
Best Practices
- Use descriptive command names and groups for better organization
- Include helpful descriptions for complex commands
- Unregister non-static commands when objects are destroyed
- Consider using method overloads for command variants
- Keep command names simple and space-free for Text Mode compatibility
- Return meaningful string results for better feedback
// Good command design example
[JahroCommand("give-item", "Gives specified item to player", "Inventory")]
public static string GiveItem(string itemName, int amount)
{
// Implementation
return $"Added {amount}x {itemName} to inventory";
}
Next Steps
Check out: