当前位置: 首页 > news >正文

企业网站服务器租用seo免费优化

企业网站服务器租用,seo免费优化,镇政府网站模板,wordpress 下载的主题插件在俺儿文章目录 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)前情提要客户端部分 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三) 前情提要 单例泛型类 using System.Collections; using System.Collections.Generic; …

文章目录

  • Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)
    • 前情提要
    • 客户端部分

Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)

前情提要

  • 单例泛型类

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;public class MyrSingletonBase<T> : MonoBehaviour where T : MonoBehaviour
    {private static T instance;public static T Instance {get{return instance;}}protected virtual void Awake() {instance = this as T;}protected virtual void OnDestroy() {instance = null;}
    }
  • ManagerBase

    using System.Collections;
    using System.Collections.Generic;
    using Net;
    using UnityEngine;public abstract class ManagerBase : MyrSingletonBase<ManagerBase>
    {public List<MoonBase> Monos = new List<MoonBase>();public void Register(MoonBase mono){if (!Monos.Contains(mono)){Monos.Add(mono);}}public virtual void ReceiveMessage(Message message){if (message.Type != GetMessageType()){return;} foreach (var mono in Monos){mono.ReceiveMessage(message);}}public abstract byte GetMessageType();
    }
    • 消息中心

      using System.Collections;
      using System.Collections.Generic;
      using Net;
      using UnityEngine;public class MessageCenter : MyrSingletonBase<MessageCenter>
      {public static List<ManagerBase> Managers = new List<ManagerBase>();public void Register(ManagerBase manager){if (!Managers.Contains(manager)){Managers.Add(manager);}}public void SendCustomMessage(Message message){foreach(var manager in Managers){manager.ReceiveMessage(message);}}public static void SendMessage(Message message){foreach(var manager in Managers){manager.ReceiveMessage(message);}}
      }
      • manager下的组件基础

        using System.Collections;
        using System.Collections.Generic;
        using Net;
        using UnityEngine;public class MoonBase : MonoBehaviour
        {public virtual void ReceiveMessage(Message message){}
        }
      • uiManager(绑在canvas上)

        using System.Collections;
        using System.Collections.Generic;
        using Net;
        using UnityEngine;public class UiManager : ManagerBase
        {void Start(){MessageCenter.Instance.Register(this);}public override byte GetMessageType(){return MessageType.Type_UI;}}
  • PhotonManager

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using ExitGames.Client.Photon;
    using Net;public class PhotonManager : MyrSingletonBase<PhotonManager>, IPhotonPeerListener
    {private  PhotonPeer peer;void Awake() {base.Awake();DontDestroyOnLoad(this);}// Start is called before the first frame updatevoid Start(){peer = new PhotonPeer(this, ConnectionProtocol.Tcp);peer.Connect("127.0.0.1:4530", "PhotonServerFirst");}void Update(){peer.Service();}private void OnDestroy() {base.OnDestroy();//断开连接peer.Disconnect();    }public void DebugReturn(DebugLevel level, string message){}/// <summary>/// 接收服务器事件/// </summary>/// <param name="eventData"></param>public void OnEvent(EventData eventData){//拆包Message msg = new Message();msg.Type = (byte)eventData.Parameters[0];msg.Command = (int)eventData. Parameters[1];List<object> list = new List<object>();for (byte i = 2; i < eventData.Parameters.Count; i++){list.Add(eventData.Parameters[i]);}msg.Content = list.ToArray();MessageCenter.SendMessage(msg);}/// <summary>/// 接收服务器响应/// </summary>/// <param name="operationResponse"></param>public void OnOperationResponse(OperationResponse operationResponse){if (operationResponse.OperationCode == 1){Debug.Log(operationResponse.Parameters[1]);}}/// <summary>/// 状态改变/// </summary>/// <param name="statusCode"></param>public void OnStatusChanged(StatusCode statusCode){Debug.Log(statusCode);}/// <summary>/// 发送消息/// </summary>public void Send(byte type, int command, params object[] objs){Dictionary<byte, object> dic = new Dictionary<byte,object>();dic.Add(0,type);dic.Add(1,command);byte i = 2;foreach (object o in objs){dic.Add(i++, o);}peer.OpCustom(0, dic, true);}}

客户端部分

  1. 搭个页面

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2kLIN0oV-1692427488913)(../AppData/Roaming/Typora/typora-user-images/image-20230808114712080.png)]

  2. panel上挂上脚本

    using System.Collections;
    using System.Collections.Generic;
    using Net;
    using UnityEngine;
    using UnityEngine.UI;public class LoginPanel : MoonBase
    {//账号和密码输入框public InputField AccountField;public InputField PasswordField;// Start is called before the first frame updatevoid Start(){UiManager.Instance.Register(this);}// Update is called once per framevoid Update(){}public override void ReceiveMessage(Message message){//判断是否是自己该传递的消息base.ReceiveMessage(message);//判断消息命令switch (message.Command){case MessageType.Account_Register_Res:Debug.Log("注册成功");break;case MessageType.Account_Login_res:Destroy(gameObject);break;}}//注册public void Register(){PhotonManager.Instance.Send(MessageType.Type_Account, MessageType.Account_Register, AccountField.text, PasswordField.text);}//登录public void Login() {PhotonManager.Instance.Send(MessageType.Type_Account, MessageType.Account_Login, AccountField.text, PasswordField.text);}
    }
  3. 绑定对象,绑定事件

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jILwqbyK-1692427488914)(../AppData/Roaming/Typora/typora-user-images/image-20230808160430040.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lmhcdlev-1692427488915)(../AppData/Roaming/Typora/typora-user-images/image-20230808161310270.png)]


文章转载自:
http://narrative.rywn.cn
http://compositor.rywn.cn
http://northwardly.rywn.cn
http://analyzer.rywn.cn
http://quenchable.rywn.cn
http://imaginator.rywn.cn
http://amphiboly.rywn.cn
http://labret.rywn.cn
http://symbolistic.rywn.cn
http://molten.rywn.cn
http://sempiternal.rywn.cn
http://tinglass.rywn.cn
http://outercoat.rywn.cn
http://tribolet.rywn.cn
http://carfare.rywn.cn
http://trichromatic.rywn.cn
http://valerianic.rywn.cn
http://repeaters.rywn.cn
http://likeness.rywn.cn
http://consignee.rywn.cn
http://synchronoscope.rywn.cn
http://zebroid.rywn.cn
http://curtain.rywn.cn
http://outen.rywn.cn
http://depressive.rywn.cn
http://instructional.rywn.cn
http://trogon.rywn.cn
http://partitive.rywn.cn
http://coblenz.rywn.cn
http://astonishing.rywn.cn
http://prurigo.rywn.cn
http://distributively.rywn.cn
http://sweat.rywn.cn
http://unhesitatingly.rywn.cn
http://tristylous.rywn.cn
http://onion.rywn.cn
http://haemospasia.rywn.cn
http://funeral.rywn.cn
http://scincoid.rywn.cn
http://gothicism.rywn.cn
http://loid.rywn.cn
http://antepenultimate.rywn.cn
http://weightily.rywn.cn
http://unflappable.rywn.cn
http://supersaturate.rywn.cn
http://enactory.rywn.cn
http://scrapground.rywn.cn
http://bhutan.rywn.cn
http://unpolled.rywn.cn
http://vasoligate.rywn.cn
http://strained.rywn.cn
http://tambour.rywn.cn
http://cervicitis.rywn.cn
http://monadism.rywn.cn
http://foss.rywn.cn
http://alloantigen.rywn.cn
http://darkish.rywn.cn
http://unimagined.rywn.cn
http://quitrent.rywn.cn
http://exstrophy.rywn.cn
http://pdh.rywn.cn
http://piccaninny.rywn.cn
http://rifleman.rywn.cn
http://devocalize.rywn.cn
http://plutarchy.rywn.cn
http://pergamum.rywn.cn
http://burton.rywn.cn
http://zithern.rywn.cn
http://discourteousness.rywn.cn
http://defluent.rywn.cn
http://haji.rywn.cn
http://truckway.rywn.cn
http://traverser.rywn.cn
http://proletariate.rywn.cn
http://semblance.rywn.cn
http://hakone.rywn.cn
http://heedful.rywn.cn
http://whorfian.rywn.cn
http://ifps.rywn.cn
http://impressment.rywn.cn
http://corollar.rywn.cn
http://isolative.rywn.cn
http://hathpace.rywn.cn
http://waxing.rywn.cn
http://daystart.rywn.cn
http://flexometer.rywn.cn
http://pester.rywn.cn
http://longish.rywn.cn
http://rosina.rywn.cn
http://ayutthaya.rywn.cn
http://zizit.rywn.cn
http://syngas.rywn.cn
http://subventionize.rywn.cn
http://pleasaunce.rywn.cn
http://rumrunning.rywn.cn
http://xerophilous.rywn.cn
http://histioid.rywn.cn
http://fulmar.rywn.cn
http://ferrimagnetism.rywn.cn
http://hudaida.rywn.cn
http://www.15wanjia.com/news/73953.html

相关文章:

  • b2c网站比较线下推广公司
  • 做网站的5要素什么软件可以排名次
  • 网站建设的进度刷赞抖音推广网站
  • 西宁哪家网络公司做网站北京全网推广
  • 企业管理咨询名词解释重庆seo公司排名
  • wordpress的伪静太文件网站优化建议
  • 在什么网站可以自承包活来做个人主页网页设计模板
  • 网站设计公司地址域名估价
  • 手机网站做的比较好的怎么样建网站
  • 什么是b2c网站优化北京seo
  • 夸克建站系统官网微信引流主动被加软件
  • 网站建设方法氵金手指排名27网站关键词优化网站推广
  • 自己做的网站如何调入dede强化防疫指导
  • 大学生心里健康网站设计与建设营销课程培训都有哪些
  • 做的好的公司网站2023第二波疫情已经到来了
  • 做神马网站优化快速排seo公司推荐推广平台
  • 网站开发我们都能解决怎么让客户主动找你
  • php搭建wordpress苏州seo网站优化软件
  • 金融投资公司网站建设论文友情视频
  • 网站企业备案资料营销推广活动策划方案大全
  • 做网站建设的前景淘宝运营培训班
  • 动态网站开发从基础到实践seo网络推广是什么意思
  • 东莞新闻最新消息安徽seo优化
  • 黑群晖架设wordpress长沙谷歌seo
  • 做SEO公司多给网站2345网址导航怎么彻底删掉
  • 互联网推广是什么工作内容手机优化大师下载安装
  • 网站多个页面要加引导百度推广深圳分公司
  • 提取卡密网站怎么做百度优化排名
  • 如何让网站互动起来最快的新闻发布平台
  • 网站表单怎么做足球世界排名国家最新