Update RemoteActions doc

This commit is contained in:
Chris Langsenkamp 2020-01-29 12:34:20 -05:00
parent e75b45f888
commit a52d58a18b

View File

@ -14,6 +14,8 @@ Commands are sent from player objects on the client to player objects on the ser
Commands functions must have the prefix “Cmd”. This is a hint when reading code that calls the command - this function is special and is not invoked locally like a normal function. Commands functions must have the prefix “Cmd”. This is a hint when reading code that calls the command - this function is special and is not invoked locally like a normal function.
> Commands cannot be used directly as event handlers e.g. UI OnClick events, either by code or by inspector assignment. Create a separate method for the handler that calls the Command.
``` cs ``` cs
public class Player : NetworkBehaviour public class Player : NetworkBehaviour
{ {
@ -52,6 +54,8 @@ ClientRpc calls are sent from objects on the server to objects on clients. They
ClientRpc functions must have the prefix “Rpc”. This is a hint when reading code that calls the method - this function is special and is not invoked locally like a normal function. ClientRpc functions must have the prefix “Rpc”. This is a hint when reading code that calls the method - this function is special and is not invoked locally like a normal function.
> ClientRpc's cannot be used directly as event handlers e.g. UI OnClick events, either by code or by inspector assignment. Create a separate method for the handler that calls the ClientRpc.
``` cs ``` cs
public class Player : NetworkBehaviour public class Player : NetworkBehaviour
{ {
@ -81,6 +85,8 @@ TargetRpc functions are called by user code on the server, and then invoked on t
The first argument to an TargetRpc function must be a NetworkConnection object. The first argument to an TargetRpc function must be a NetworkConnection object.
> TargetRpc's cannot be used directly as event handlers e.g. UI OnClick events, either by code or by inspector assignment. Create a separate method for the handler that calls the TargetRpc.
This example shows how a client can use a Command to make a request from the server (`CmdMagic`) by including its own `connectionToClient` as one of the parameters of the TargetRpc invoked directly from that Command: This example shows how a client can use a Command to make a request from the server (`CmdMagic`) by including its own `connectionToClient` as one of the parameters of the TargetRpc invoked directly from that Command:
``` cs ``` cs