File tree Expand file tree Collapse file tree 1 file changed +29
-26
lines changed Expand file tree Collapse file tree 1 file changed +29
-26
lines changed Original file line number Diff line number Diff line change @@ -23,33 +23,36 @@ void MyMethod(int myInt)
23
23
24
24
#### Convenience Example
25
25
``` csharp
26
- private void OnGUI ()
27
- {
28
- if (GUILayout .Button (" SendRandomInt" ))
29
- {
30
- if (IsServer )
31
- {
32
- InvokeClientRpcOnEveryone (MyClientRPC , Random .Range (- 50 , 50 ));
33
- }
34
- else
35
- {
36
- InvokeServerRpc (MyServerRpc , Random .Range (- 50 , 50 ));
37
- }
38
- }
39
- }
40
-
41
- [ServerRPC ]
42
- private void MyServerRPC (int number )
43
- {
44
- Debug .Log (" The number received was: " + number );
45
- Debug .Log (" This method ran on the server upon the request of a client" );
46
- }
47
-
48
- [ClientRPC ]
49
- private void MyClientRPC (int number )
26
+ public class Example : NetworkedBehaviour
50
27
{
51
- Debug .Log (" The number received was: " + number );
52
- Debug .Log (" This method ran on the client upon the request of the server" );
28
+ private void OnGUI ()
29
+ {
30
+ if (GUILayout .Button (" SendRandomInt" ))
31
+ {
32
+ if (IsServer )
33
+ {
34
+ InvokeClientRpcOnEveryone (MyClientRPC , Random .Range (- 50 , 50 ));
35
+ }
36
+ else
37
+ {
38
+ InvokeServerRpc (MyServerRpc , Random .Range (- 50 , 50 ));
39
+ }
40
+ }
41
+ }
42
+
43
+ [ServerRPC ]
44
+ private void MyServerRPC (int number )
45
+ {
46
+ Debug .Log (" The number received was: " + number );
47
+ Debug .Log (" This method ran on the server upon the request of a client" );
48
+ }
49
+
50
+ [ClientRPC ]
51
+ private void MyClientRPC (int number )
52
+ {
53
+ Debug .Log (" The number received was: " + number );
54
+ Debug .Log (" This method ran on the client upon the request of the server" );
55
+ }
53
56
}
54
57
```
55
58
You can’t perform that action at this time.
0 commit comments