- Home /
Question by
twoface262 · Jan 26, 2012 at 12:33 AM ·
javascriptnetworkingrpcchat
Network Chat not sending messages to other clients
I'm having a problem where my network chat script isn't sending the messages for to or from other players. :/ here is the script -
var mySkin : GUISkin;
var userName : String;
private var windowRectT = Rect (10,310,700,20);
var scrollViewVector : Vector2;
private var outputText : String = "";
private var inputText : String = "";
function OnGUI () {
if(networkView.isMine){
GUI.skin = mySkin;
windowRectT = GUILayout.Window (0, windowRectT,ChatWindow, "Chat");
}
}
function ChatWindow () {
GUILayout.Label ("User Name:");
userName = GUILayout.TextField (userName);
GUILayout.Label("Message: ");
scrollViewVector = GUILayout.BeginScrollView (scrollViewVector);
GUILayout.TextArea (outputText);
GUILayout.EndScrollView();
GUILayout.Label ("Chat:");
inputText = GUILayout.TextField (inputText);
if (GUILayout.Button ("Send")) {
networkView.RPC ("SendChat", RPCMode.All, userName + ": " + inputText);
inputText = "";
}
GUI.DragWindow (Rect (0,0,1000,1000));
}
@RPC
function SendChat (text : String) {
if(networkView.isMine)
{
Debug.Log("chat sent!!!");
outputText += (text + "\n");
}
}
Thanks for the help everyone!
(Anyone can feel free to use this in there game if needed as a base code for chat, but if you find a fix please post it. Thanks!)
Comment
Answer by ankush20 · Jan 21, 2015 at 11:28 AM
Hello,
Try This, may be it will help you :
http://www.lynda.com/Unity-3D-tutorials/Simple-chat-clients/160270/177284-4.html
Thanks
Your answer
Follow this Question
Related Questions
RPC failed to send 1 Answer
A couple of questions about Networking. 0 Answers
Sending an RPC 1 Answer
Sending Data through RPC 2 Answers
Networking When Offline 1 Answer