问题描述
是否可以使用 jint 来操作使用 XNA (C#) 创建的 3D 环境,并添加此环境的功能(再次使用 jint)?
Is it possible to use jint to manipulate a 3D environment created with XNA (C#), and to add functionality to this environment (again using jint)?
推荐答案
作为 Jint 的贡献者,我向您推荐 Jint.Jint 使它比 Lua 更简单.此外,我不知道这是否适用于 Lua,但您可以给它 .NET 对象并在 javascript 中使用它们(Jint 代表 Javascript INTpreter).您还可以使用权限集保护您的应用程序.这是之前使用 Jint 提供的相同代码:
As a contributor to Jint, I would recommend you Jint. Jint makes it more simple than what Lua does. Moreover, I don't know if this is possible with Lua, but you can give it .NET objects and play with them in javascript (Jint stands for Javascript INTpreter). You can also secure your application with Permissions Set. Here is the same code provided before with Jint :
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.Run();
}
private void Run()
{
JintEngine engine = new JintEngine();
engine.SetFunction("GTest", new Jint.Delegates.Func<object, double>(LUA_GTest));
engine.Run("GTest([['3,3']])");
}
private double LUA_GTest(object d)
{
Console.WriteLine("Got {0} - {1}", d.GetType().ToString(), d.ToString());
while (d is ArrayList)
{
d = ((ArrayList)d)[0];
Console.WriteLine("Got {0} - {1}", d.GetType().ToString(), d.ToString());
}
if (d is string)
{
d = double.Parse((string)d);
Console.WriteLine("Got {0} - {1}", d.GetType().ToString(), d.ToString());
}
if (d is double)
return (double)d * 2;
return 0;
}
}
这篇关于Jint + XNA (C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!