我正在尝试为我的游戏添加运行时脚本,但在加载外部脚本时遇到了问题:
CSharpScript.RunAsync(scriptToRun, null, this);当要运行的脚本使用宿主程序中的类时。
示例:
主机程序有一个名为Ship scriptToRun的类,它有:
Ship badGuy = new Ship();在执行时
CSharpScript.RunAsync(scriptToRun, null, this);我明白了:
error CS0246: The type or namespace name 'Ship' could not be found (are you missing a using directive or an assembly reference?)我假设我需要添加一个对脚本的引用,但是我不能弄清楚。
谢谢。
发布于 2018-09-14 16:44:11
var result = await CSharpScript.EvaluateAsync("Ship()", ScriptOptions.Default.WithReferences(typeof(Ship).Assembly));https://stackoverflow.com/questions/46671956
复制相似问题