- Home /
Question by
amy42 · May 09, 2016 at 04:58 PM ·
multiplayernetworkrpc
Problem with RPC attribute.
Hi! I have a problem, and i cant solve this :(
Problem:
RPC call failed because the function 'SendMessage' in 'Component' does not have the RPC attribute. You need to add the RPC attribute in front of the function declaration UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) chat:windowFunc(Int32) (at Assets/Server/chat.cs:29) UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, GUISkin, Int32, Single, Single, GUIStyle)
Code:
using UnityEngine; using System.Collections;
public class chat : MonoBehaviour {
private Rect windowRect = new Rect (200, 200, 300, 400);
private string messBox = "", messagetoSend = "";
public NetworkView nView;
void Start()
{
nView = GetComponent<NetworkView>();
}
private void OnGUI()
{
windowRect = GUI.Window (1, windowRect, windowFunc, "Chat");
}
private void windowFunc(int id)
{
GUILayout.Box (messBox, GUILayout.Height (350));
GUILayout.BeginHorizontal ();
messagetoSend = GUILayout.TextField (messagetoSend);
if (GUILayout.Button("Send", GUILayout.Width(75)))
{
nView.RPC("SendMessage", RPCMode.All, messagetoSend);
//NetworkView.RPC("SendMessage", RPCMode.All, messagetoSend + "\n");
}
GUILayout.EndHorizontal();
//pour bouger la fenettre
GUI.DragWindow (new Rect (0, 0, Screen.width, Screen.height));
}
[RPC]
private void SendMessage(string mess)
{
messBox += mess;
}
}
Comment
Thats what I mean dude, he's using Photon not UNet. NetworkViews etc etc gives it away.
[ClientRpc] is for UNet.
If this were UNet the name of the Function would need to be RpcSend$$anonymous$$essage, but its not.