结论,唯一可行的方法是3,把matlab打包成exe,在unity中用代码调用exe
然而1/2都最后都TM遇到这个error!!!NotImplementedException: The requested feature is not implemented. 感觉是Unity版本问题,根本没有实现这个功能,所以最后我用了下面这个方法。
用application compiler打包出来的会有splash界面,直接编译的只会有命令行界面
用c#调用exe并传参
string argument1 = """ + "test.png" + """;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = System.Environment.CurrentDirectory + "\frommatlab\skeleton.exe";
process.StartInfo.Arguments = argument1;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
//启动
process.Start();
//等exe结束在运行后面的代码
process.WaitForExit();