多人开源游戏_开源高级多人网络层

多人开源游戏

What has been open sourced exactly?

到底什么是开源的?

The multiplayer feature can be split into a lower and higher layer. The lower one is the transport layer, mostly residing in the NetworkTransport class. This layer exists inside the Unity engine and is written in C++. Its main purpose is to provide a thin layer above socket access and we optimized it for performance. Above this, we have the high level API, which is written in C# and exists in a modular extension DLL. This extension DLL has been open sourced and you can modify/extend it and replace the one shipped with Unity. It’s released under the MIT/X11 license, which means you can use it as you like and there are no restrictions or requirements for contributing back any changes.

多人游戏功能可以分为较低和较高的一层。 较低的一层是传输层,主要位于NetworkTransport类中。 该层存在于Unity引擎内部,并用C ++编写。 其主要目的是在套接字访问上方提供一个薄层,我们对其性能进行了优化。 在此之上,我们有高级API,该API用C#编写并且存在于模块化扩展DLL中。 该扩展DLL是开源的,您可以对其进行修改/扩展,并替换Unity附带的DLL。 它是根据MIT / X11许可发布的,这意味着您可以随意使用它,并且对回馈任何更改没有任何限制或要求。

两个抽象层次。 (Two levels of abstraction.)

The manual has a good overview for what you can do with the high level API. There are many classes inside the extension DLL and you could consider this split into two layers as well. Using the NetworkClient and NetworkServer classes, you could set up connectivity manually or use the NetworkManager or NetworkLobbyManager for even higher level access. You can add these managers to a game object for immediate connectivity options with another built-in HUD component. You can also extend them to perform custom behaviours. It’s designed to be client/server based and server authoritative (with a few client authority exceptions you could use). These classes are a good reference for how you could use the transport level yourself, to implement your own custom high level API. Even if you don’t intend to change anything, I can recommend you take a look at these to learn more about how the high level works.

该手册 很好地概述了您可以使用高级API进行的操作。 扩展DLL中有许多类,您也可以考虑将此分为两层。 使用NetworkClient和NetworkServer类,可以手动设置连接性,也可以使用NetworkManager或NetworkLobbyManager进行更高级别的访问。 您可以将这些管理器添加到游戏对象中,以便与另一个内置HUD组件立即连接。 您还可以扩展它们以执行自定义行为。 它被设计为基于客户端/服务器并且具有服务器权威性(可以使用一些客户端权限例外)。 这些类是您如何自己使用传输级别,实现自己的自定义高级API的很好参考。 即使您不打算进行任何更改,我也建议您查看这些内容,以了解有关高级功能的更多信息。

需要考虑的几件事。 (A few things to consider.)

Three Visual Studio project files come with the source: one for runtime, another for editor and finally the editor-runtime. The last one is for the runtime version, which runs when in PlayMode in the editor. The update method here is pumped from the engine itself so you need to have the NetworkIdentity.UNetUpdate() function around or nothing will happen when running. We have a code generation step which runs every time the user assembly is compiled in the editor. This generator is called the UNetWeaver and we’re considering open sourcing that too. It parses the NetworkBehaviours and generates serialization code, Command/ClientRPC handlers, lookup tables and so on. The names of these things (SyncVar, Command, etc) need to stay the same for these things to continue functioning.

源附带了三个Visual Studio项目文件:一个用于运行时,另一个用于编辑器,最后是编辑器运行时。 最后一个用于运行时版本,该运行时版本在编辑器中的PlayMode中运行。 这里的更新方法是从引擎本身抽取的,因此您需要具有NetworkIdentity.UNetUpdate()函数,否则运行时将不会发生任何事情。 我们有一个代码生成步骤,该步骤每次在编辑器中编译用户程序集时运行。 该生成器称为UNetWeaver,我们也在考虑开源。 它解析NetworkBehaviours并生成序列化代码,Command / ClientRPC处理程序,查找表等。 这些东西(SyncVar,Command等)的名称需要保持相同,这些东西才能继续起作用。

Get the open source repository on Bitbucket.

Bitbucket 上获取开源存储库

翻译自: https://blogs.unity3d.com/2015/11/19/high-level-multiplayer-networking-layer-has-been-open-sourced/

多人开源游戏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值