Unity3D 的网络部署是如何工作的?
只需单击一个按钮,它就非常流畅且跨浏览器/平台,这导致非技术类型得出结论,整个引擎本质上比我们现在使用的更好。仅仅是他们花时间实现了 Unity WebPlayer 的所有浏览器/操作系统插件版本并对其进行了完善,还是引擎架构的设置方式有更深层次的内容?
It's very slick and cross browser/platform at the click of a button, which is leading non-technical types to conclude the entire engine is intrinsically better than what we use now. Is it simply that they've taken the time to implement all the per-browser/OS plugin versions of Unity WebPlayer and polish it, or is there anything deeper in the way the engine architecture is set up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Unity 采用用 C#、UnityScript(基于 JavaScript)或 Boo(基于 Python)编写的脚本,并将它们编译成 mono 程序集。这些程序集+游戏所需的 3D 模型、声音和纹理被压缩到由浏览器插件加载的 .unity3d 文件中。由于几乎所有游戏逻辑都在托管单声道程序集中,因此它可以跨平台运行,并且几乎没有特定于平台的怪癖。
他们最近重写了插件检测和安装代码,这样就可以很容易地将一段 javascript 放入网页中,如果用户有插件,则显示 Unity 内容;如果用户有插件,则显示其他内容(图像、Flash、视频)。不。我相信他们的插件支持Mac和Windows上的所有A级浏览器,并且无需重新启动浏览器即可安装该插件。
Unity 引擎的优点之一是您可以采用大量现成的托管程序集并将它们包含在您的项目中并从 Unity 代码中调用它们。但您必须意识到这些程序集确实会使 .unity3d 文件的大小膨胀。
另一个优点是您可以轻松编写公开可调参数的组件,这些参数可以由非技术人员修改。
还有一个优点是,编写良好的项目可以在一天之内移植到 iPhone、Standalone、Android、Web 等设备或从 iPhone、Standalone、Android、Web 等设备移植。我个人通过修改我的输入处理程序和更改纹理压缩来完成 iPhone 到 Web 的工作。
一个很大的缺点是,由于应用程序正在运行托管代码,因此对于好奇或恶意的人来说,将程序集反编译为完全可读的代码并不是太困难。因此,您需要考虑有人可以利用这些信息做什么(在多人游戏中作弊、编写机器人、伪造高分等)。混淆程序集是可能的,但将此步骤添加到构建过程中并非易事。
Unity takes scripts written in C#, UnityScript (based on JavaScript), or Boo (based on Python), and compiles them into mono assemblies. Those assemblies + the 3d models, sounds, and textures required by your game are compressed into a .unity3d file that is loaded by their browser plugin. Since almost all of the game's logic is in managed mono assemblies it runs cross platform with very few platform specific quirks.
They've recently rewritten their plugin detection and installation code so that it is very easy to drop a block of javascript into a web page that shows Unity content if the user has the plugin, or other content (image, flash, video) if they don't. I believe their plugin supports all A-class browsers on Mac and Windows, and the plugin can be installed without restarting the browser.
One advantage of the Unity engine is that you can take a lot of off-the-shelf managed assemblies and include them in your project and call them from Unity code. But you have to be aware that these assemblies can really bloat the size of the .unity3d file.
Another advantage is that you can easily write components that expose tunable parameters that can be modified by non-technical people.
And yet another advantage is that a well written project can be ported to/from iPhone, Standalone, Android, Web, etc. in under a day. I've personally done iPhone to Web by just modifying my input handler and changing texture compression.
One big disadvantage is that since the application is running managed code it is not too difficult for a curious or malicious person to decompile the assemblies into completely readable code. So you need to think about what someone could do with that info (cheat in multiplayer, write bots, falsify high scores, etc.). It is possible to obfuscate your assemblies, but it isn't trivial to add this step to your build process.