[Unity&Photon]Photon Chat 对话框测试
来源:互联网 发布:最新韩国网络剧2017 编辑:程序博客网 时间:2024/05/16 15:52
本文主要是根据 参考资料1,进行的测试。
Photon Chat Intro 手册地址如下所示
https://doc.photonengine.com/en-us/chat/current/getting-started/chat-intro
新建 对象 UI 如下所示,
Panel_Intro 的界面如下所示
Panel_Msg 页面如下所示
文本框位置如下所示:
新建一个空对象,命名为Chat,其设置如下所示
Photon Engine 官网 : https://www.photonengine.com/en-US/Photon
在Photon Engine 官网,登录账号,点击如下图所示位置
给App 自定义 一个名字
复制 App ID
找到 Resources 文件夹下面 的 PhotonServerSettings
PhotonServerSettings的设置如下所示,把复制 的App ID 粘贴到如下图所示的 Chat AppId 位置
---------------------------------------------------------------------------------------
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using ExitGames.Client.Photon.Chat;//using ExitGames.Client.Photon;using System;public class TC_chat : MonoBehaviour, IChatClientListener{ public ChatClient chatClient; public InputField p1rName; public Text connectionState; private string worldChat; public InputField msgInput; public Text msgArea; public GameObject introPanel; public GameObject msgPanel; private void Start() { Application.runInBackground = true; if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.ChatAppID)) { print(" No chat ID provided "); return; } { print(" Have ID provided "); } connectionState.text = "Connecting...."; worldChat = "world"; } private void Update() { if (this.chatClient != null) this.chatClient.Service(); } public void getConnected() { print("Trying to connect"); this.chatClient = new ChatClient(this);// this.chatClient.Connect(PhotonNetwork.PhotonServerSettings.ChatAppID,"anything",new ExitGames.Client.Photon.Chat.AuthenticationValues(p1rName.text));// //string str_var = "Connecting to chat"; connectionState.text = "Connecting to chat";// //this.chatClient.Connect(ChatSettings.Instance.AppId, "1.0", new ExitGames.Client.Photon.Chat.AuthenticationValues(UserName)); } public void sendMsg() { Debug.Log(" 提交信息 "); this.chatClient.PublishMessage(worldChat,msgInput.text); } #region public void DebugReturn(DebugLevel level, string message) { } public void OnDisconnected() { Debug.Log("************************** DisConnected"); } public void OnConnected() { msgArea.text = ""; introPanel.SetActive(false); msgPanel.SetActive(true); connectionState.text = "Conncted"; Debug.Log("************************** Connected"); this.chatClient.Subscribe(new string[] { "world"});//worldChat = "world" this.chatClient.SetOnlineStatus(ChatUserStatus.Online); //OnSubscribed(new string[] { worldChat },new bool[]{true });//worldChat = "world" } public void OnChatStateChange(ChatState state) { } public void OnGetMessages(string channelName, string[] senders, object[] messages) { // Debug.Log(" msgArea "+msgArea); if (msgArea!=null) { for (int i = 0; i < senders.Length; i++) { msgArea.text += senders[i] + " : " + messages[i] + "\n"; } } } public void OnPrivateMessage(string sender, object message, string channelName) { } public void OnSubscribed(string[] channels, bool[] results) { connectionState.text = "In World Chat"; this.chatClient.PublishMessage(worldChat,"Joined"); } public void OnUnsubscribed(string[] channels) { } public void OnStatusUpdate(string user, int status, bool gotMessage, object message) { } #endregion}
---------------------------------------------------------------------------------------
可能会遇到的问题
state 字符串 显示不全,进行如下设置
如果是
public class TC_chat : MonoBehaviour, IChatClientListener
问题,查看参考资料2
---------------------------------------------------------------------------------------
参考资料:
1.PUN : Photon Unity Network - Photon Chat Intro
2.
[Unity&接口]子类即继承接口类也继承MonoBehaviour的快速操作和重构实现
3.
4.
- [Unity&Photon]Photon Chat 对话框测试
- [Unity&photon]photon chat入门
- Unity链接Photon服务器
- Unity Photon服务器
- Unity Photon服务器(二)
- [Unity&photon]photon导入Unity的详细步骤教程
- [Unity&photon]photon导入Unity 建立工程 详细步骤教程
- unity基础开发-photon服务器
- [Unity]Photon多人场景
- unity连接photon服务端模块
- Unity环境搭建Photon服务器
- photon Unity RPC 调用流程
- photon Unity RPC 调用流程
- [Unity&photon&多人游戏插件]photon入门
- Photon Unity Networking 案例(一)
- Photon Unity Networking(PUN)的简单使用
- Unity连Photon服务器入门详解
- unity服务器Photon Server学习笔记
- Android assets和res资源目录的简单梳理
- 47.路由器设置
- 二叉树的深度和路径和问题
- 4.2 模拟域频域变换
- C++ STL priority_queue
- [Unity&Photon]Photon Chat 对话框测试
- 正则表达式
- NSTimer使用注意事项
- js一次性输入一个数组求平均值
- 第四届“图灵杯”NEUQ-ACM程序设计竞赛(团队赛)-网络同步赛F(矩阵快速幂)
- python学习日记(6)
- 国际国家代码与区号查询
- 【转载】简单词法分析器的实现
- 多线程死锁的一个简单例子