Skip to content

Commit

Permalink
Helloworld added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ized06 committed Jun 20, 2017
1 parent e2e420e commit a49560e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/plugin/develop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,42 @@ The benefit of implementing an UnrealCV command are:
1. You can use the communication protocol provided by UnrealCV to exchange data between your program and UE4.
2. You can share your code with other researchers, so that it can be used by others.

First we go through a very simple example which prints a message. Assume that we want to add a commamd :code:`vget /object/helloworld` to print "Hello World!". We need to modify two files: :file:`ObjectHandler.h` and :file:`ObjectHandler.cpp`.

In :file:`ObjectHandler.h`, we need to add a member function:

.. code:: c
   FExecStatus HelloWorld(const TArray<FString>& Args);
In :file:`ObjectHandler.cpp`, we define this member function:

.. code:: c
   FExecStatus FObjectCommandHandler::HelloWorld(const TArray<FString>& Args)
{
FString Msg;
Msg += "Hello World!";
return FExecStatus::OK(Msg);
}
Then we need to bind the command with the function:

.. code:: c
void FObjectCommandHandler::RegisterCommands()
{
...
Cmd = FDispatcherDelegate::CreateRaw(this, &FObjectCommandHandler::HelloWorld);
Help = "Print Hello World";
CommandDispatcher->BindCommand(TEXT("vget /object/helloworld"), Cmd, Help);
...
}
After the modification, we can compile and use the new command.

Here we will walk you through how to implement a command :code:`vset /object/[id]/rotation` to enable you set the rotation of an object.

:code:`FExecStatus` return the exec result of this command. The result will be returned as a text string.
Expand Down

0 comments on commit a49560e

Please sign in to comment.