Click or drag to resize

StrixBehaviourRpc Method (String, Object)

Calls an RPC on the room member who owns the object.

Namespace:  SoftGear.Strix.Unity.Runtime
Assembly:  StrixUnityRuntime (in StrixUnityRuntime.dll) Version: 1.5.0
Syntax
C#
public void Rpc(
	string rpcName,
	params Object[] args
)

Parameters

rpcName
Type: SystemString
RPC method name.
args
Type: SystemObject
A list of method arguments. This should match the arguments in the method definition, both in number and respective types.
Remarks
The method has to be defined on the same class and marked with StrixRpcAttribute attribute. Target member must be in the same match room as you.
Examples
using SoftGear.Strix.Unity.Runtime;
using UnityEngine;
using UnityEngine.UI;

public class StrixRpcExample : StrixBehaviour
{
    [StrixSyncField]
    public int Health = 100;
    public Image HealthBar;

    private void OnMouseDown()
    {
        Rpc("Hit", Random.Range(3, 8));
    }

    [StrixRpc(ProcedureCode = 1)]
    public void Hit(int damage)
    {
        Health = Mathf.Max(0, Health - damage);
    }

    public void Update()
    {
        HealthBar.fillAmount = Health / 100f;
    }
}
See Also