From a52d58a18b292827cf581ed9c388c1bf60424bf7 Mon Sep 17 00:00:00 2001 From: Chris Langsenkamp Date: Wed, 29 Jan 2020 12:34:20 -0500 Subject: [PATCH] Update RemoteActions doc --- doc/Guides/Communications/RemoteActions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/Guides/Communications/RemoteActions.md b/doc/Guides/Communications/RemoteActions.md index 80e5d7c09..f89960b7e 100644 --- a/doc/Guides/Communications/RemoteActions.md +++ b/doc/Guides/Communications/RemoteActions.md @@ -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 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 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'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 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. +> 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: ``` cs