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 + "
");
}
}
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!)