- Home /
RPC can't send string?
Hey guys,
I'm trying to send a string through an RPC, but I'm getting two errors that I haven't been able to fix yet. The errors and code are bellow respectively.
(23,29): error CS1502: The best overloaded method match for `UnityEngine.NetworkView.RPC(string, UnityEngine.RPCMode, params object[])' has some invalid arguments
(23,29): error CS1503: Argument `#1' cannot convert `method group' expression to type `string'
using System;
using UnityEngine;
using System.Collections;
public class ChatManager : MonoBehaviour
{
string userName;
public SpriteText allText;
public SpriteText userMessage;
void Start ()
{
userName = GameObject.Find("Network").GetComponent<NetworkCode>().userAlias;
}
void Post ()
{
GetAndPostText ();
string message = allText.Text + "\n" + userName + ": " + userMessage.Text;
networkView.RPC (MessageToPost, RPCMode.Others, message);
}
void GetAndPostText ()
{
allText.Text = allText.Text + "\n" + userName + ": " + userMessage.Text;
userMessage.text = "enter message here";
userMessage.Text = "enter message here";
}
[RPC]
void MessageToPost (string message)
{
allText.Text = message;
}
}
Thanks for all your help! Gibson
networkView.RPC ($$anonymous$$essageToPost, RPC$$anonymous$$ode.Others, message); by the error the 1st argument should a be a string and not a method.
But, it is a string. Also, I tried just making it "test", and that didn't work either
Sorry Jeffom, I thought you were talking about the message part. I really appreciate your help!
Answer by Bunny83 · Jul 02, 2012 at 10:50 PM
Jeffom is right, the first argument has to be a string. You didn't use a string, you used a method. It should look like this:
networkView.RPC ("MessageToPost", RPCMode.Others, message);
Oh, I see; sorry about the confusion (on my part)! Thanks for your help
Your answer
Follow this Question
Related Questions
how to properly clean up the NetworkView to prevent errors ? 0 Answers
Multiplayer Moving Bullet 1 Answer
Check RPC is from Server 1 Answer
RPC call not sending correct data 0 Answers