Unity3D可视化编程第三方工具背后的机制

发布于 2024-12-07 09:08:59 字数 639 浏览 0 评论 0 原文

First sorry for posting this here.I just got no answer to this question on "Unity Answers"I have been looking into the tools like uScript or Strumpy Shader Editors which are node based visual programming tools like Unreal Kismet or 3DsMax particle flow system. I have been researching on how in fact these tools generate the source code in Unity.So I assume that during the node logic assembly the code should be generated and compiled to DLLs (in Unity all the source code is compiled into DLLs)dynamically.I started looking into such C# assemblies like Reflections , Microsoft.CSharp and System.CodeDom.Compiler; I even tried to write a C# class in Unity via the editor as a text and then parse and compile it into DLL using the above mentioned tools(it was ok but the DLL was existing only during the Runtime in the temp..) Therefore I would like to know is this the approach those tools are likely to use? Or there is a better and cleaner way to do it ?Thanks .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蛮可爱 2024-12-14 09:08:59

我实际上正在做同样的事情。我认为您在编译器类方面走在正确的道路上。我不认为你可以在移动设备上动态发出 IL 作为安全沙箱问题,但我正在动态创建 C# 代码并将其编译成这样的持久 dll。

CompilerParameters compilerParameter = new CompilerParameters();
compilerParameter.OutputAssembly = "/Your/Path/Here.dll";
CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("CSharp");

StringBuilder code = new StringBuilder();
code.AppendLine("public static class Test {");
//More code here...
code.AppendLine("}");
var compilerResult = codeDomProvider.CompileAssemblyFromSource(compilerParameter, code.ToString());

希望这会有所帮助。

I'm actually in the process of doing the same thing.. I think you are on the right path with the Compiler classes. I dont think you can emit IL on the fly on mobile devices as a security sandbox issue but I'm dynamically creating c# code and compiling it into persistent dll's like this..

CompilerParameters compilerParameter = new CompilerParameters();
compilerParameter.OutputAssembly = "/Your/Path/Here.dll";
CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("CSharp");

StringBuilder code = new StringBuilder();
code.AppendLine("public static class Test {");
//More code here...
code.AppendLine("}");
var compilerResult = codeDomProvider.CompileAssemblyFromSource(compilerParameter, code.ToString());

Hope this helps..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文