简体   繁体   English

从 HTML 或命令提示链接向独立的 Unity 应用程序发送消息?

[英]Send message to standalone Unity application from HTML or command prompt link?

Is there a way to send a message to Unity standalone build from external source?有没有办法从外部源向 Unity 独立构建发送消息? The source could be an html created file or a link through PDF or even from command prompt.源可以是 html 创建的文件或通过 PDF 甚至来自命令提示符的链接。 I have not started anything since I need an idea of how to approach this.我还没有开始任何事情,因为我需要知道如何解决这个问题。

I finally found a solution.我终于找到了解决方案。 Here is my C# script:这是我的 C# 脚本:

static string cmdInfo = "";

     void Start () 
     {
         string[] arguments = Environment.GetCommandLineArgs();
         foreach(string arg in arguments)
         {
             cmdInfo += arg.ToString() + "\n ";
         }
     }



     void OnGUI()
     {
         Rect r = new Rect(5,5, 800, 500);
         GUI.Label(r, cmdInfo);
     }

and from the project build folder, I am running the following command from command prompt:并从项目构建文件夹中,我从命令提示符运行以下命令:

Halo2 --UserCreated -One

"Halo2" is basically the app name and other two are the arguments. “Halo2”基本上是应用名称,其他两个是 arguments。

The first time I run the above command, it opens the app.我第一次运行上述命令时,它会打开应用程序。 Unfortunately the second time I run the app, it opens another instance of the same app.不幸的是,我第二次运行该应用程序时,它会打开同一应用程序的另一个实例。 Is there a way to make the command prompt pass the arguments to the same app without opening new one?有没有办法让命令提示符将 arguments 传递给同一个应用程序而不打开新的应用程序?

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

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