- Reference the GorillaRPC mod (
GorillaRPC.dll) in your mod. - Make sure this is above the BepInPlugin attribute:
[BepInDependency("Steve.GorillaRPC")]using GorillaRPC.Types;
using UnityEngine;
public class YourRPCClass : GorillaRPCBehaviour
{
// Your RPC methods go here
}RPC methods require the [GorillaRPC] attribute.
[GorillaRPC("MethodName", 101)]
private void YourMethod(string param1, int param2)
{
Debug.Log($"Received RPC call with {param1} and {param2}");
// Handle the RPC here
}- Method name (string)
- Event code (byte: 0–255)
0, 1, 2, 3, 4, 5, 8, 9, 50, 51, 176, 199 — Automatically blocked
Call the method across the network:
Call(
nameof(YourMethod), // Method name
new object[] { "Hello", 42 }, // Parameters
this, // Target behavior
101, // Event code (must match attribute)
Photon.Realtime.ReceiverGroup.Others // Receiver group
);ReceiverGroup.Others- All other players (not you)ReceiverGroup.All- Everyone, including youReceiverGroup.MasterClient- Only the Master Client
// Create a new GameObject with your RPC behavior
var rpcObject = new GameObject("RPCHandler").AddComponent<YourRPCClass>();
// Or add to an existing GameObject
gameObject.AddComponent<YourRPCClass>();using GorillaRPC.Types;
using Photon.Pun;
using UnityEngine;
public class PlayerMessage : GorillaRPCBehaviour
{
[GorillaRPC("DisplayMessage", 120)]
private void DisplayMessage(string message)
{
Debug.Log($"[Remote] {message}");
}
public void SendMessageToAll(string message)
{
Call(
nameof(DisplayMessage),
new object[] { message },
this,
120,
Photon.Realtime.ReceiverGroup.All
);
}
}- RPC methods are auto-registered on
Awake(). - Each RPC method must have a unique event code + method name pair.
- RPC parameters must be Photon-serializable.
