rintText", RPCMode.All, "Hello world");This code will use the attached Network View to invoke all "
rintText()" functions in any scripts attached to the same GameObject.这段代码使用绑定的NetworkView来执行所有绑定在同一个游戏对象上的脚本组件中的"
rintText()"RPC函数。The first parameter of RPC() is the name of the function to be invoked, the second determines who will have this function invoked. In this case we invoke the RPC call on everyone who is connected to the server but did not tell him to buffer the call for clients which connect later.RPC的第一个参数是被执行的函数的名字。第二个参数据决定在哪一个位置执行该函数。在这个例子中,我们会在所有连接到这个服务器的客户端中执行这个RPC调用但不会为后续连接上的客户端缓存这个调用。All the following parameters are the parameters that will be passed to the RPC function and be sent across the network. In this case, "Hello World" will be sent as a parameter and be passed as the text parameter in the PrintText function.然后接下来的参数都会通过网络传递给RPC函数执行方作为函数参数,在这个例子中,"Hello, world"会作为一个参数被传递,并做为PrintText函数的文本参数。You can also get hold of an extra internal parameter, a NetworkMessageInfo s***ct which holds details like who sent the RPC. You do not need to specifically pass in this information, so the PrintText function shown above will be invoked exactly the same but can be declared as:你还可以添加一个额外的保持了谁发送这个RPC的细节的NetworkMessageInfo结构的内部参数,你不需要在调用时特别的指明,因此PrintText函数可以修改为如下形式而执行过程依然和上述代码相同@RPC| 欢迎光临 纳金网 (http://go.narkii.com/club/) | Powered by Discuz! X2.5 |