简体   繁体   English

如何在 Unity Editor 中运行两个游戏窗口

[英]How to run two game windows in Unity Editor

What do I mean by two game windows in the Unity Editor? Unity 编辑器中的两个游戏窗口是什么意思?

Well if one could basically be able to have two separate windows inside the editor instead of being limited to having just one:好吧,如果人们基本上能够在编辑器中拥有两个单独的窗口,而不是仅限于只有一个:

Why would this be useful?为什么这会有用?

It's mostly useful for networking .它主要用于网络 When testing a networked multiplayer game, normally one would have to wait a long time to create a standalone build to test and debug events, plus debugging errors on standalone is hard.在测试联网多人游戏时,通常需要等待很长时间才能创建独立构建来测试和调试事件,而且在独立上调试错误很困难。

If I could just run two instances (one server/ one client) on the click of the play button I would save so much time.如果我可以通过单击播放按钮运行两个实例(一个服务器/一个客户端),我会节省很多时间。

This is a game window btw https://i.gyazo.com/2aeb04f8a41f1508d262cf9a526311bc.png这是一个游戏窗口顺便说一句https://i.gyazo.com/2aeb04f8a41f1508d262cf9a526311bc.png

If you are trying to test networking code, having multiple "game windows" open won't actually allow you to do that.如果您正在尝试测试网络代码,打开多个“游戏窗口”实际上并不允许您这样做。 If you have multiple copies of the project on your computer you can open multiple instances of unity.如果您的计算机上有多个项目副本,您可以打开多个 unity 实例。 (unity puts a lock file in each project so you can't just open it twice using the same files) (unity 会在每个项目中放置一个锁定文件,因此您不能使用相同的文件将其打开两次)

Downside to this is that if you make changes in one project, you have to copy/redo that change in the copy of the project.这样做的缺点是,如果您在一个项目中进行更改,则必须在项目副本中复制/重做该更改。 But certainly faster than building and you can connect debuggers to both instances of unity但肯定比构建更快,您可以将调试器连接到两个统一实例

You can create multiple directories and link "Assets", "Packages" and "ProjectSettings" from the origin to your copies.您可以创建多个目录并将“资产”、“包”和“项目设置”从源链接到您的副本。 then all your changes are applied to all instances.那么您的所有更改都会应用于所有实例。

on windows: "mklink /d target source" on mac: "ln -s source target"在 Windows 上:“mklink /d 目标源”在 mac 上:“ln -s 源目标”

you still have to apply a few settings in each instance ( like selected platform )您仍然需要在每个实例中应用一些设置(例如所选平台)

PS: make sure you modify your unique identifier in each copy instance to be able to act as different user/account. PS:确保在每个副本实例中修改您的唯一标识符,以便能够充当不同的用户/帐户。 this should editor only and can help switch accounts to test different right/behavior这应该只是编辑器,可以帮助切换帐户以测试不同的权利/行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM