本文主要是根据 参考资料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);}#regionpublic 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.

[UnityPhoton]Photon Chat 对话框测试相关推荐

  1. wxHtml 示例:关于对话框测试

    wxHtml 示例:关于对话框测试 wxHtml 示例:关于对话框测试 wxHtml 示例:关于对话框测试 #include "wx/wxprec.h" #ifndef WX_PR ...

  2. 控件测试功能点摘要2

    WEB页面常用基本控件测试用例 一.树控件的测试外观操作 1)项目中的所有树是否风格一致 2)树结构的默认状态是怎样的.比如默认树是否是展开,是展开几级? 是否有默认的焦点? 默认值是什么?展开的节点 ...

  3. 直接用Win32 API创建对话框Demo

    Win32 API包含有对话框函数: Win10,CFree 5.0:新建一个窗口工程: 先看一下CFree自带对话框编辑器:其保存为.DRES:还不知道怎么加入工程:先不管: #include &l ...

  4. VC++对话框学习总结

    VC++中如何复制对话框资源 http://www.cnblogs.com/Yogurshine/p/3710566.html 法1: 在你的工程中添加另一个工程的rc文件,这时资源视图中就会出现两个 ...

  5. Photon多人游戏开发教程

    PUN介绍 入门 Photon Unity Networking(首字母缩写PUN)是一个Unity多人游戏插件包.它提供了身份验证选项.匹配,以及快速.可靠的通过我们的Photon后端实现的游戏内通 ...

  6. html对话框跳转页面,html页面的简单对话框(alert, confirm, prompt)

    html页面简单的三种对话框如下: 1.alert(),最简单的提示框: alert("你好!"); 2.confirm(),有确认和取消两个按钮: if(confirm(&quo ...

  7. 【pyqt5学习】——对话框QDialog学习(QMessageBox、QColorDialog、QFIleDialog、QFontDialog、QInputDialog)

    目录 1.对话框QDialog类别 2.通用对话框 ​编辑 3.消息对话框QMessageBox() 1)消息对话框QMessageBox类型 2)案例 ​编辑 4.输入对话框QInputDialog ...

  8. 用HTML5做一个类似于智能对话的可以自动回复的网页对话框

    背景 作为一个入门级编程小白(现在正处于大三阶段,感觉学校教的东西实在是太少了,还是得自学)来说,自己动手做一些个小项目的时候,就会萌发一些奇怪的想法,但是呢我对这样一些奇怪的想法有时又不知从何处下手 ...

  9. 【Unity3D插件】Photon Unity Networking(PUN)插件分享《多人联机服务器》

    推荐阅读 CSDN主页 GitHub开源地址 Unity3D插件分享 简书地址 我的个人博客 QQ群:1040082875 一.前言 Photon Unity Networking (PUN)是一种用 ...

最新文章

  1. Spyder更改默认工作路径已经文件路径
  2. Nginx学习之二-配置项解析及编程实现
  3. 使用MakeCAB.exe命令创建CAB文件
  4. 行如风 Angular 初识3
  5. 在ASP.NET AJAX 1.0框架中访问Web服务
  6. springboot开发的项目上传图片到服务器后不能访问
  7. OpenCV扫描图像对象的实例(附完整代码)
  8. Java方法中的参数太多,第7部分:可变状态
  9. CTS(12)---android 兼容性测试 CTS 测试过程
  10. python程序开机自启动_Linux下Python脚本自启动和定时启动的详细步骤
  11. c语言i o编程,【linux】基本I/O操作标准I/O操作(c语言编程)
  12. 中国物联网潜力巨大 还需加快投资节奏
  13. 持久化存储-对象序列化(摘自网络)
  14. 通俗的语言解释一下什么是 RPC 框架
  15. /usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: glibconfig.h: No such file or directory
  16. linux下拷贝某一时间段的文件
  17. Ubuntu调整缩放
  18. 机器学习入门好文,强烈推荐
  19. Win10 1809美化
  20. 串行通信协议(I2C、SPI、UART、SCCB、CAN)

热门文章

  1. 【Linux】 - Linux中的键盘快捷操作
  2. ​争夺00后社交,QQ、B站、快手谁能赢?
  3. osg 根据两个点的经纬度计算方位角
  4. 优雅!用了这两款插件,我成了整个公司代码写得最规范的码农
  5. 在pc端上操作手机工具分享
  6. Latex中在字母上加上波浪线
  7. 如何创建用户和组?怎样添加用户呢?windows dos命令
  8. 我的世界杯 - 诸神黄昏之战
  9. IT职场法则七条——献给正在努力奋斗的你们
  10. Excel与PowerBI 之PowerQuery 编辑界面异同-PowerQuery 系列文章之三