我想使用IronPython作爲Unity3D的外部腳本語言。 IronPython的執行加載所需的DLL在Assets \ Plugins中很好。但是,當我嘗試運行腳本時,出現此錯誤:Unity3D IronPython
PythonImportErrorException: No module named UnityEngine
IronPython.Modules.Builtin.__import__ (IronPython.Runtime.Calls.ICallerContext,string,object,object,object) <IL 0x0003b, 0x001cc>
(wrapper dynamic-method) object.__import__##5 (IronPython.Runtime.Calls.ICallerContext,object,object,object,object) <IL 0x0000e, 0x0004d>
IronPython.Runtime.Calls.FastCallableWithContextAny.Call (IronPython.Runtime.Calls.ICallerContext,object,object,object,object) <IL 0x00015, 0x00067>
IronPython.Runtime.Calls.BuiltinFunction.Call (IronPython.Runtime.Calls.ICallerContext,object,object,object,object) <IL 0x0000d, 0x00058>
IronPython.Runtime.Operations.Ops.CallWithContext (IronPython.Runtime.Calls.ICallerContext,object,object,object,object,object) <IL 0x00012, 0x000b0>
IronPython.Runtime.Importer.Import (IronPython.Runtime.PythonModule,string,IronPython.Runtime.List) <IL 0x0000d, 0x0006c>
IronPython.Runtime.Operations.Ops.Import (IronPython.Runtime.PythonModule,string) <IL 0x00007, 0x0003b>
(wrapper dynamic-method) object.<string>##1 (IronPython.Runtime.ModuleScope) <IL 0x0006b, 0x00210>
腳本和'UnityEngine.dll'位於同一個文件夾中。這是腳本:
import clr
clr.LoadAssemblyFromFile("UnityEngine.dll")
import UnityEngine
from UnityEngine import *
Debug.Log("Hello World from Python!")
出於興趣:爲什麼IronPython的? – 2012-08-02 15:23:05
它允許我使用基於Mono.NET構建的Unity3D – 2012-08-02 15:49:45
Unity3d支持Boo開箱即用,它非常接近Python;我想知道爲什麼你特意在那裏嵌入IronPython。 – 2012-08-03 07:17:30