.Net compatible

main
Kevin Li 2023-09-04 14:06:38 +08:00
parent bb3faf86af
commit d754eebc6d
3 changed files with 48 additions and 42 deletions

View File

@ -9,20 +9,39 @@
## 安装 .NET 6.0 运行时必须使用6.0版本) ## 安装 .NET 6.0 运行时必须使用6.0版本)
* 下载离线安装包 * 下载离线安装包
https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-6.0.21-macos-x64-installer - Mac: https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/sdk-6.0.413-macos-x64-installer
- Windows: https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/sdk-6.0.413-windows-x64-installer
* 或者使用 homebrew * Mac下建议使用 homebrew
brew tap isen-ng/dotnet-sdk-versions brew tap isen-ng/dotnet-sdk-versions
brew install --cask dotnet-sdk6-0-400 brew install --cask dotnet-sdk6-0-400
## 安装 protobuf-net.Protogen 命令行程序 ## 安装 protobuf-net.Protogen 命令行程序
dotnet tool install --global protobuf-net.Protogen --version 3.2.12 dotnet tool install --global protobuf-net.Protogen --version 3.2.12
## 进入项目目录 * Windows
cd upm_guru_dof_lib/Runtime/ServerProtos protogen 的安装目录为 C:\Users\用户名\.dotnet\tools ,可直接在 cmd 命令行下运行 protogen
* Macos
在 Macos 下 protogen 的安装目录为 /Users/用户名/.dotnet/tools可能需要手动将
```
PATH=PATH:/Users/用户名/.dotnet/tools
```
加入到 ~/.bash_profile中因为 homebrew 加入的 PATH ~/.dotnet/tools 无效
## 生成 cs 文件 ## 生成 cs 文件
~/.dotnet/tools/protogen messages.proto --csharp_out=../NetworkGen
* Windows
```
cd DofKcpDemo\ServerProtos
protogen messages.proto --csharp_out=..\Assets\Scripts\NetworkGen
```
* MacOS
```
cd DofKcpDemo/ServerProtos
~/.dotnet/tools/protogen messages.proto --csharp_out=../Assets/Scripts/NetworkGen
```
## 安装和接入 ## 安装和接入
@ -30,25 +49,12 @@ cd upm_guru_dof_lib/Runtime/ServerProtos
- 本插件需要使用公司内部的Gitlab加载对应的repo, 详见 [Castbox内部git服务器Gitea使用指南](https://docs.google.com/document/d/1DiGPDD5Teu2QcYaBhqAcsqMbb3DJ5sdnTQMuvVzJSUk/edit#heading=h.w9tkkzwwyjxf) - 本插件需要使用公司内部的Gitlab加载对应的repo, 详见 [Castbox内部git服务器Gitea使用指南](https://docs.google.com/document/d/1DiGPDD5Teu2QcYaBhqAcsqMbb3DJ5sdnTQMuvVzJSUk/edit#heading=h.w9tkkzwwyjxf)
- 根据文档部署好本机配置后, 请在Unity内部配置如下参数 - 根据文档部署好本机配置后, 请在Unity内部配置如下参数
- TBD - 修改位于项目Packages/manifest.json文件在dependencies中添加
- TBD ```
- TBD {
"dependencies": {
"com.guru.unity.gurukcp": "git@git.chengdu.pundit.company:castbox/upm_guru_dof_lib.git",
## 逻辑实现 ...
}
- TBD }
```
## 问题答疑
- Q
> A
- Q
> A
- Q
> A

View File

@ -29,7 +29,7 @@ namespace Guru
_isDebugMode = is_debug_mode; _isDebugMode = is_debug_mode;
if(_isDebugMode) if (_isDebugMode)
{ {
Debug.Log($"[GameEventMgr]Init: Running in debug mode"); Debug.Log($"[GameEventMgr]Init: Running in debug mode");
} }
@ -49,17 +49,17 @@ namespace Guru
} }
} }
private readonly Queue<List<Delegate>> _listenerListQueue = new (); private readonly Queue<List<Delegate>> _listenerListQueue = new Queue<List<Delegate>>();
private readonly Queue<List<DelegateGameObjectBonding>> _listenerBondingListQueue = new (); private readonly Queue<List<DelegateGameObjectBonding>> _listenerBondingListQueue = new Queue<List<DelegateGameObjectBonding>>();
private readonly Dictionary<int, List<Delegate>> _eventTable = new (); private readonly Dictionary<int, List<Delegate>> _eventTable = new Dictionary<int, List<Delegate>>();
private readonly Dictionary<int, List<DelegateGameObjectBonding>> _eventObjTable = new (); private readonly Dictionary<int, List<DelegateGameObjectBonding>> _eventObjTable = new Dictionary<int, List<DelegateGameObjectBonding>>();
private readonly Dictionary<int, List<Delegate>> _pendingAddTable = new (); private readonly Dictionary<int, List<Delegate>> _pendingAddTable = new Dictionary<int, List<Delegate>>();
private readonly Dictionary<int, List<DelegateGameObjectBonding>> _pendingObjAddTable = new (); private readonly Dictionary<int, List<DelegateGameObjectBonding>> _pendingObjAddTable = new Dictionary<int, List<DelegateGameObjectBonding>>();
private readonly Dictionary<int, List<Delegate>> _pendingRemoveTable = new (); private readonly Dictionary<int, List<Delegate>> _pendingRemoveTable = new Dictionary<int, List<Delegate>>();
private readonly Dictionary<int, List<DelegateGameObjectBonding>> _pendingObjRemoveTable = new (); private readonly Dictionary<int, List<DelegateGameObjectBonding>> _pendingObjRemoveTable = new Dictionary<int, List<DelegateGameObjectBonding>>();
// Using raising event list to prevent infinite loop call or changing delegate list // Using raising event list to prevent infinite loop call or changing delegate list
private readonly List<int> _raisingEventIds = new (); private readonly List<int> _raisingEventIds = new List<int>();
private GameEventMgr() { } private GameEventMgr() { }
@ -133,7 +133,7 @@ namespace Guru
for (int i = 0; i < listeners.Count; i++) for (int i = 0; i < listeners.Count; i++)
{ {
if(listeners[i].gameObject == null) if (listeners[i].gameObject == null)
{ {
listeners.RemoveAt(i--); listeners.RemoveAt(i--);
} }
@ -143,7 +143,7 @@ namespace Guru
private List<Delegate> SpawnDelegateList() private List<Delegate> SpawnDelegateList()
{ {
if(_listenerListQueue.Count > 0) if (_listenerListQueue.Count > 0)
{ {
return _listenerListQueue.Dequeue(); return _listenerListQueue.Dequeue();
} }
@ -410,7 +410,7 @@ namespace Guru
{ {
var listener = listeners[i]; var listener = listeners[i];
if(listener != null) if (listener != null)
{ {
try try
{ {
@ -423,7 +423,7 @@ namespace Guru
LogException(ex, event_id.ToString(), "DoRaise"); LogException(ex, event_id.ToString(), "DoRaise");
} }
} }
} }
} }
_raisingEventIds.Remove(event_id); _raisingEventIds.Remove(event_id);

View File

@ -16,7 +16,7 @@ namespace DofLibrary
{ {
private long _cid; private long _cid;
private Ukcp _client; private Ukcp _client;
private MemoryStream _localSendMs = new(1024 * 1024 * 1); private MemoryStream _localSendMs = new MemoryStream(1024 * 1024 * 1);
/// <summary> /// <summary>
/// 设置 kcp 客户端,用于发送消息 /// 设置 kcp 客户端,用于发送消息