代码拉取完成,页面将自动刷新
using UnityEngine;
using System;
using System.Collections;
using KBEngine;
/*
可以理解为插件的入口模块
在这个入口中安装了需要监听的事件(installEvents),同时初始化KBEngine(initKBEngine)
*/
public class KBEMain : MonoBehaviour
{
public KBEngineApp gameapp = null;
// 在unity3d界面中可见选项
public bool isMultiThreads = true;
public string ip = "127.0.0.1";
public int port = 20013;
public KBEngineApp.CLIENT_TYPE clientType = KBEngineApp.CLIENT_TYPE.CLIENT_TYPE_MINI;
public string persistentDataPath = "Application.persistentDataPath";
public bool syncPlayer = true;
public int threadUpdateHZ = 10;
public int SEND_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
public int RECV_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
void Awake()
{
DontDestroyOnLoad(transform.gameObject);
}
// Use this for initialization
void Start ()
{
MonoBehaviour.print("clientapp::start()");
installEvents();
initKBEngine();
}
public virtual void installEvents()
{
}
public virtual void initKBEngine()
{
// 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs
KBEngineArgs args = new KBEngineArgs();
args.ip = ip;
args.port = port;
args.clientType = clientType;
if(persistentDataPath == "Application.persistentDataPath")
args.persistentDataPath = Application.persistentDataPath;
else
args.persistentDataPath = persistentDataPath;
args.syncPlayer = syncPlayer;
args.threadUpdateHZ = threadUpdateHZ;
args.SEND_BUFFER_MAX = (UInt32)SEND_BUFFER_MAX;
args.RECV_BUFFER_MAX = (UInt32)RECV_BUFFER_MAX;
args.isMultiThreads = isMultiThreads;
if(isMultiThreads)
gameapp = new KBEngineAppThread(args);
else
gameapp = new KBEngineApp(args);
}
void OnDestroy()
{
MonoBehaviour.print("clientapp::OnDestroy(): begin");
KBEngineApp.app.destroy();
MonoBehaviour.print("clientapp::OnDestroy(): end");
}
void FixedUpdate ()
{
KBEUpdate();
}
public virtual void KBEUpdate()
{
// 单线程模式必须自己调用
if(!isMultiThreads)
gameapp.process();
KBEngine.Event.processOutEvents();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。