ServerDemo

2018-03-26  本文已影响0人  醉酒青牛_fa4e

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 ();
}

}

上一篇下一篇

猜你喜欢

热点阅读