https://github.com/mukarillo/unitydebugconsole
This tool will help you debug game features while playing without having to create a debug panel from scratch.
https://github.com/mukarillo/unitydebugconsole
debugging-tool game-development unity unity-scripts unity-tools unity3d-plugin
Last synced: about 2 months ago
JSON representation
This tool will help you debug game features while playing without having to create a debug panel from scratch.
- Host: GitHub
- URL: https://github.com/mukarillo/unitydebugconsole
- Owner: Mukarillo
- License: mit
- Created: 2018-12-02T00:01:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-26T06:23:12.000Z (over 5 years ago)
- Last Synced: 2025-03-17T05:02:12.002Z (2 months ago)
- Topics: debugging-tool, game-development, unity, unity-scripts, unity-tools, unity3d-plugin
- Language: C#
- Homepage:
- Size: 13.1 MB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# UnityDebugConsole
This tool will help you debug game features while playing without having to create a debug panel from scratch.
![]()
## How to use
*you can find a pratical example inside this repository in Main scene*### 1 - Place DebugConsole folder on your project (`DebugConsole.cs` and `DebugConsoleAttribute.cs`)
### 2 - Add ```[DebugConsole("name", "description")]``` attribute to any method in any class that is referenced by `Assembly-CSharp.dll`
```c#
public class Exemple : MonoBehaviour
{
private int lives;
[DebugConsole("Add Lives", "This method add lives to the player.")]
public void AddLives(int amount)
{
lives += amount;
}
}
```### 3 - Drag DebugConsole class to any GameObject and call ```DebugConsole.Instance.Open``` to open the console at anytime.
![]()
## DebugConsole `public` overview
### Methods
> `DebugConsole.Open`
- *Description*: Start rendering the console/buttons. It also will call `RefreshMethods`.> `DebugConsole.Close`
- *Description*: Stop rendering the console/buttons.> `DebugConsole.RefreshMethods`
- *Description*: This method will verify witch `MonoBehaviour` objects are active and have the Custom Attribute. It is supposed to be called on `OnDestroy` method in a script that has a method with DebugConsole attribute.> `DebugConsole.AddInstanceMethod`
- *Description*: Use this to register methods at run-time. It will allow you to specify the instance wich the method willbe called.- *Parameters* :
|name |type |description |
|--|--|--|
|`id` |**string** |*Unique ID to reference the instance method.* |
|`methodName` |**string** |*Text to be displayed in the console button title.* |
|`methodDescription` |**string** |*Text to be displayed in the console button description.* |
|`target` |**object** |*Instance reference to the object.* |
|`method` |**Action** |*Method to be called.* |> `DebugConsole.RemoveInstanceMethod`
- *Description*: Use this to remove methods that were previous registered using its `id`.- *Parameters* :
|name |type |description |
|--|--|--|
|`id` |**string** |*Unique ID to reference the instance method.* |## Considerations
* This tool is just for debug purposes. It heavily relies on Reflection, so it's not supposed to be used in release builds.
* If the method was registered with the Custom Attribute, there is no way to know in wich instance the method is supposed to be called, so it will call the first object it finds with `FindObjectOfType`. If the method is in a class that it doesn't inherit from MonoBehaviour, it will create another instance of that class and call that method. If the method is static, it doesn't need an instance, so it will call it normally.
* If you wish to invoke the method in an specific instance, register the method using `DebugConsole.Instance.AddInstanceMethod`.
* You use the DebugConsole attribute in `public`, `private` and `static` methods.
* The method can have as many parameters as you wish. But only `int`, `float`, `string` and `bool` are being considered.
* All Custom Attribute valid parameters are:
* Simple types (bool, byte, char, short, int, long, float, and double)
* string
* enums
* object (The argument to an attribute parameter of type object must be a constant value of one of the above types.)
* one-dimensional arrays of any of the above types
* To be able to use the types that are not being considered go to `DebugConsole.cs` at line `133` and add another verification to that method and draw the correct GUI elements to send to the method. **(if you do that, please consider sending a pull request 😊)**