示例#1
0
    //Callback (Executed locally on the server)
    public void OnGameObjectInteraction(NetworkMessage netMsg)
    {
        InteractionMessage msg = netMsg.ReadMessage <InteractionMessage> ();

        Debug.Log("Message received " + msg.ToString());
        NetworkInstanceId netId = new NetworkInstanceId(msg.netId);
        GameObject        go    = NetworkServer.FindLocalObject(netId);

        PlayerCommands.OnGameObjectInteraction(go, msg.method, msg.args);
    }
示例#2
0
    public void SendInteractionMessage(GameObject go, string method, object[] args)
    {
        NetworkIdentity ni = go.GetComponent <NetworkIdentity> ();

        if (ni == null)
        {
            Log("No network Identity found on the object");
            return;
        }
        uint netId             = ni.netId.Value;
        InteractionMessage msg = new InteractionMessage(netId, method, args);

        if (!client.Send(INTERACTION_MSG_ID, msg))
        {
            Log("Problem while sending msg:\n " + msg.ToString());
        }
    }