美文网首页
[UnityxWinCmd][工具链]如何在Unity里调用编写

[UnityxWinCmd][工具链]如何在Unity里调用编写

作者: XTST | 来源:发表于2018-04-26 16:05 被阅读0次

最近做工程遇到一点小麻烦。

项目是一个WebGL项目,Unity负责展示和表现,后端C++写了一套算法,Unity提供数据,算法算完了返回数据显示。

看起来很简单,但是调试起来简直要死人了:每次调试都需要发布->清除浏览器缓存->重新打开浏览器进入工程->测试。最要命的是WebGL平台我现在还没有发现什么比较好的工具来辅助调试,只能通过原始的打Log来猜测发生了什么。这可以说极大的拖慢了我的开发进度。

为了解决这些问题,稍微百度了一下,参考了文章 的内容,做了一套简单工具。

核心还是上文中的代码

private static void processCommand(string command, string argument, Action<string> handler)
    {
        ProcessStartInfo start = new ProcessStartInfo(command);
        start.Arguments = argument;
        start.CreateNoWindow = false;
        start.ErrorDialog = true;
        start.UseShellExecute = false;

        if (start.UseShellExecute)
        {
            start.RedirectStandardOutput = false;
            start.RedirectStandardError = false;
            start.RedirectStandardInput = false;
        }
        else
        {
            start.RedirectStandardOutput = true;
            start.RedirectStandardError = true;
            start.RedirectStandardInput = true;
            start.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;
            start.StandardErrorEncoding = System.Text.UTF8Encoding.UTF8;
        }

        Process p = Process.Start(start);

        if (!start.UseShellExecute)
        {
            handler.Invoke(p.StandardOutput.ReadToEnd());
        }

        p.WaitForExit();
        p.Close();
    }

稍稍加了一点封装,毕竟我也是要利用和处理输出字符串的。

然后绑定到编辑器扩展或者临时UI的按钮事件去,就可以用了。

相关文章

网友评论

      本文标题:[UnityxWinCmd][工具链]如何在Unity里调用编写

      本文链接:https://www.haomeiwen.com/subject/xvcmlftx.html