Hey i keep getting this error Type UnityEngine does not contain a definition for RPC
Im trying to create a muiltiplayer chat system watching this video Unity3D Networking 8: Simple Chat System - YouTube
but doesn’t seem to work here is the code
using System.Collections.Generic;
using UnityEngine;
public class Chat : MonoBehaviour
{
public List chatHistory = new List();
private string currentMessage = string.Empty;
private void OnGui()
{
GUILayout.BeginHorizontal(GUILayout.Width(250));
currentMessage = GUILayout.TextField(currentMessage);
if (GUILayout.Button("Send"))
{
if (!string.IsNullOrEmpty(currentMessage.Trim()))
{
networkView.RPC("ChatMessage", RPCMode.AllBuffered, new object[] { currentMessage });
currentMessage = string.Empty;
}
}
GUILayout.EndHorizontal();
foreach (string c in chatHistory)
GUILayout.Label(c);
}
[RPC]
public void ChatMessage(string message)
{
chatHistory.Add(message);
}
}