美文网首页
ServerDemo

ServerDemo

作者: 醉酒青牛_fa4e | 来源:发表于2018-03-26 23:59 被阅读0次

    using UnityEngine;
    using System.Collections;
    using System.IO;
    using System;

    // 服务器实现.
    public class ServerDemo : MonoBehaviour
    {
    //临时消息接收
    string currentMsg = "";
    Vector2 scrollViewPosition;

    void Start ()
    {
        scrollViewPosition = Vector2.zero;
        //消息委托
        NetUtility.Instance.SetDelegate ((string msg) => {
            Debug.Log (msg);
            currentMsg += msg + "\r\n";
        });
        //开启服务器
        NetUtility.Instance.ServerStart ();
    }
    
    void OnGUI ()
    {
        scrollViewPosition = GUILayout.BeginScrollView (scrollViewPosition, GUILayout.Width (700), GUILayout.Height (1000));
        //消息展示
        GUILayout.Label (currentMsg);
        GUILayout.EndScrollView ();
    }
    

    }

    相关文章

      网友评论

          本文标题:ServerDemo

          本文链接:https://www.haomeiwen.com/subject/aqndcftx.html