public class Chat : MonoBehaviour { bool usingChat = false; bool showChat = false; string inputField = ""; Vector2 scrollposition; int width = 500; int height = 200; string playerName; float lastUnfocusTime = 0; Rect window; ArrayList playerList = new ArrayList(); class PlayerNode { public string playerName; public NetworkPlayer player;//NetworkPlayer是一个数据结构,保存着你可以从网络定位的另一位玩家的信息。比如,基于NetworkPlayer你可以向另外一个玩家发送消息。 } ArrayList chatEntries=new ArrayList(); class ChatEntry { public string name=""; public string text=""; } // Use this for initialization void Start () { window = new Rect(Screen.width / 2-width/2,Screen.height-height+5,width,height); } void OnConnectedToServer() { playerName = PlayerPrefs.GetString("playerName",""); if(playerName=="") { playerName = "RandomName"+Random.Range(1,999); } ShowChatWindow(); |
unity3d中实现聊天功能
最新推荐文章于 2025-05-30 11:38:22 发布