1 Star 0 Fork 0

子弹大仙/kbengine_unity3d_plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
KBEMain.cs 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
liquidx 提交于 2015-02-13 18:57 . up
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();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/BulletHermit/kbengine_unity3d_plugins.git
[email protected]:BulletHermit/kbengine_unity3d_plugins.git
BulletHermit
kbengine_unity3d_plugins
kbengine_unity3d_plugins
master

搜索帮助