Skip to content

Commit

Permalink
Update README and CHANGELOG formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzil committed Apr 25, 2015
1 parent 0e1442a commit b9fbb7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Change list
- Include 3 built-in commands
* HELP - Display the list of available commands or details about a specific command.
* LOAD - Load the specified scene by name. Before you can load a scene you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there.
* QUIT - Quit the application.
* ``HELP`` - Display the list of available commands or details about a specific command.
* ``LOAD`` - Load the specified scene by name. Before you can load a scene you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there.
* ``QUIT`` - Quit the application.
- Allow the overwriting of an existing command by simply registering a new command with the same name
- Add optional parameters ``description`` and ``usage`` to the simpler overload of ``ConsoleCommandsDatabase.RegisterCommand()``
- Improve the explanatory text in the sample scenes
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Anywhere in your code, simply use ``Console.Log()`` to output to the console

## Default Commands
The console comes with three commands by default.
* HELP - Display the list of available commands or details about a specific command.
* LOAD - Load the specified scene by name. Before you can load a scene you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there.
* QUIT - Quit the application.

* ``HELP`` - Display the list of available commands or details about a specific command.
* ``LOAD`` - Load the specified scene by name. Before you can load a scene you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there.
* ``QUIT`` - Quit the application.

## Extending the Console
Use the ``ConsoleCommandsDatabase.RegisterCommand()`` method to register your own commands. Here's an example.
Expand All @@ -26,8 +27,13 @@ public class MyCommands : MonoBehaviour
{
void Start()
{
ConsoleCommandsDatabase.RegisterCommand("TAKE", MyCommands.Take, description: "Partake in a great adventure alone.", usage: "TAKE");
ConsoleCommandsDatabase.RegisterCommand("RANDOM", MyCommands.Random, description: "Display a random number between a and b using an optional seed.", usage: "RANDOM a b [seed]");
ConsoleCommandsDatabase.RegisterCommand("TAKE", MyCommands.Take,
description: "Partake in a great adventure alone.",
usage: "TAKE");

ConsoleCommandsDatabase.RegisterCommand("RANDOM", MyCommands.Random,
description: "Display a random number between a and b using an optional seed.",
usage: "RANDOM a b [seed]");
}

private static string Take(params string[] args)
Expand All @@ -41,7 +47,7 @@ public class MyCommands : MonoBehaviour
{
return "Missing range bounds.";
}

if (args.Length >= 3)
{
int seed = 0;
Expand All @@ -58,7 +64,7 @@ public class MyCommands : MonoBehaviour
float a = 0;
float b = 0;
if (float.TryParse(args[0], out a) &&
float.TryParse(args[1], out b) &&
float.TryParse(args[1], out b) &&
a <= b)
{
return Convert.ToString(UnityEngine.Random.Range(a, b));
Expand Down
Binary file modified UnityConsole.unitypackage
Binary file not shown.

0 comments on commit b9fbb7f

Please sign in to comment.