简体   繁体   English

如何在C#程序中运行“无头”(无GUI)Unity3D游戏?

[英]How can I run a “headless” (no GUI) Unity3D game inside a C# program?

I would like to execute only the model part of a game, without a GUI of any sort. 我只想执行游戏的模型部分,而没有任何类型的GUI。

As such, I would instantiate some classes from Unity3D, arrange them somehow, "start" them whatever that means, and periodically read the state of the components inside the game, or else receive update events from them. 因此,我将从Unity3D实例化一些类,以某种方式安排它们,以任何方式“启动”它们,并定期读取游戏中组件的状态,或者从中接收更新事件。

Currently I have already the Unity DLLs available with a NuGet Package , but I don't know how to go on from here: 目前,我已经可以使用NuGet软件包提供Unity DLL ,但是我不知道如何从这里继续:

public class HelloUnity3D
{
    void run()
    {
        var myGame = new UnityEngine.MonoBehaviour();

        //myGame.WhatNow(?)
    }
}

No, it's impossible. 不,这是不可能的。

AFAIK, MonoBehaviour is executed by the editor or players (playback engine) of Unity3D-you can find them in unity3d_install_dir\\Editor\\Data\\PlaybackEngines on Windows. AFAIK, MonoBehaviour由Unity3D的编辑器或播放器(播放引擎)执行-您可以在Windows的unity3d_install_dir \\ Editor \\ Data \\ PlaybackEngines中找到它们。

So if you want to "execute only the model part of a game", you have to write a modeling-only playback engine. 因此,如果要“仅执行游戏的模型部分”,则必须编写仅建模的播放引擎。 But I don't think that can be done without access to source code of Unity3D. 但是我认为如果没有访问Unity3D的源代码就无法做到这一点。

But it's possible to run MonoBehaviour codes that doesn't run code that requires Unity3D playback engines. 但是可以运行不运行需要Unity3D播放引擎的代码的MonoBehaviour代码。

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

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