Skip to content

Instantly share code, notes, and snippets.

@rje
Created February 19, 2015 23:55
Show Gist options
  • Save rje/4ec5c120f7c25b0d2ba2 to your computer and use it in GitHub Desktop.
Save rje/4ec5c120f7c25b0d2ba2 to your computer and use it in GitHub Desktop.
public class ConsoleCommandRouter : MonoBehaviour {
void Start () {
var repo = ConsoleCommandsRepository.Instance;
repo.RegisterCommand("toggle_boolean", ToggleBoolean);
}
public string ToggleBoolean(params string[] args) {
// args is an array of strings representing all the words after "toggle_boolean" on the console line you typed
// here is where you'd want to find whatever GameObject or class you'd want to modify and do your thing
// might look something like:
GameObject go = GameObject.Find("My GameObject");
MyComponent comp = go.GetComponent<MyComponent>();
bool oldValue = comp.MyBoolean;
comp.MyBoolean = !oldValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment