Coder Social home page Coder Social logo

poisonersc / jumpcommand Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjcat/jumpcommand

0.0 0.0 0.0 584 KB

A develop console for Unity let you input command string to execute debug functions. Only one line code to register custom command.

License: MIT License

C# 100.00%

jumpcommand's Introduction

JumpCommand

A develop console for Unity let you input command string to execute debug functions.

######Read Chinese Version中文版

Screenshot

screenshot

Installation

  1. Copy JumpCommand directory to your project folder.
  2. Create a GameObject in the scene and add a JumpCommandGUI component to it.
  3. Run your game and press ~ to open command input.
  4. Input some command and press Enter to execute, press and to get history command.
  5. Press ~ again to close command input.

Registering Custom Commands

JumpCommand can only register static function and class function that inherited from Monobehaviour. If the function's parameter type is not native type(int, float, double, string, bool, enum), you will need write Type Converter for you custom parameter type.

  1. Add CommandItem to function
  2. If the function is Monobehaviour, you need select GameObject at Hierarchy window when you call it.

Here is a example:

[CommandItem("test","output integer")]
static public void CommandTest(int i) {
    Debug.Log(i.ToString());
}

We have registered a command named test with help text "output integer", build-in command ls can list all commands and help text. Now input test 10 as a command we can get a output message 10 in Console.

If you want to change a person's speed from command like speed 0.5, add CommandItem to AdjustSpeed, and make sure when you input the command you have selected the GameObject you want to invoke.

//Person.cs
public class Person :  MonoBehaviour {
    //...
	[CommandItem("speed","Change person speed")]
	public void AdjustSpeed(float value) {
	    speed += value;
	}
	//...
}

If the function is static, just add CommandItem and call it. If the function is Monobehaviour class, add CommandItem and select the GameObject when you call it.

Write Type Converter for Custom Parameter Type

Most native data types (int, float, double, string, bool, enum) have default type converters, so you don't need to write converts for them. JumpCommand can convert string arguments to proper parameters. If you want to use custom parameter type, you need to write Type Converter for your type. There is a reference How to: Implement a Type Converter at MSDN show you how to write a converter to convert string to Point class.

Contact Author

Feel free to ask me any question.

[email protected]

jumpcommand's People

Contributors

jjcat avatar aosyang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.